What is the best practice in this case?
I want to create a vending machine simulation program.
The design will be something like this :
GUI----use----VendingMachine----has----ProductStorage
Previously, i want everything inside VendingMachine will be transparent from the GUI.
The GUI just use VendingMachine, and it has no knowledge about ProductStorage.
But then i realize that in order for the GUI to display the products, it has to use ProductStorage.
So i came up with adding this getter to VendingMachine class :
public ProductStorage getStorage()
return storage;
}I'm breaking the rules of encapsulation.
Is it okay to do this? What is the practice in this case?
Thanks,
Ang.
GUI----use----VendingMachine----has----ProductStorage
Previously, i want everything inside VendingMachine will be transparent from the GUI.
The GUI just use VendingMachine, and it has no knowledge about ProductStorage.
But then i realize that in order for the GUI to display the products, it has to use ProductStorage.Not necessarily. You can expose the ProductStorage interface (did I get this right: methods such as getProductList(), getProductQuantity(String productId) ?), in VendingMachineImpl. That latter can simply delegates to its ProductStorage collaborator. The GUI code doesn't need to know this latter is a separate instance.
I'm breaking the rules of encapsulation.
Is it okay to do this? What is the practice in this case?Technically you're violating the so-called Law of Demeter, which as you mention means you reveal implementation details to the client - and makes it less flexible, if you ever want to move ProductStorage API in another class. For example it would exhibit transaction logic to the client code.
OK we're talking about a far-fetched exemple, part of an exercise, but in general you should avoid this.
Similar Messages
-
WhatâÃÂÃÂs the best practice for this scenario?
Hi,
My users want the ability to change the WHERE and/or ORDER BY clause at runtime. They may define user preferences on each screen ( which is bind to a view object). They want to see the same records based on WHERE/ORDER BY defined on the last visit. That is why I keep the users preferences and load the screen based on that, using :
View.setWhereClause(...);
View.setOrderByClause(...);
View.executeQuery();
This works good when only one user working with the application but faced low performance when more than one user working with the application.
What are the points to increase the performance and what is the best practice for this scenario?
Thanks for your help in advance.Sung,
I am talking only about 2 users in my testing. I am sure i missed something but could not recognize that.
This page is my custom query page including a tag to instantiate app module in stateful mode at the top <jbo:ApplicationModule..> and a tag to instantiate data source <jbo:Datasource...> and release tag at the bottom <jbo:ReleasePageResources..> and some java code in the middle(body). The java code constructed the query statement and then fires the query to set the view object based on the query statement using the above methods.
So, I am facing very slow performance(speed) when two clients load this page at the same time. Looks like the entire application locks for others when one client load this page and fire the query. i realized the battle neck is where executeQuery() is executing.
what do you think.
Thanks in advance for your comments. -
What is the best practice for this?
Hi,
I have a huge package, let's say including 100 procedures.
These procedures(with package name qualifier) are called all around the application. Now i want to divide it to 5 packages each one including 20 procedures.
What is the best practice to do this with minimum changes in the application?First step before doing anything with OD is to make certain that local DNS services are correct. To verify that, launch Terminal.app from Applications > Utilities on the test server, and issue the following harmless, diagnostic command:
sudo changeip -checkhostname
You'll need to enter your administrative password for the sudo to be accepted.
If the output from that command reports no changes are required, then an export from the original OD and an import into the test system would be typical for testing, if you trust what's in the original OD. -
Coalesce or compress this index? what is the best solution in this case?
BANNER
Oracle Database 10g Enterprise Edition Release 10.2.0.4.0 - 64biI have executed the following query on a specific index that I suspected to be smashed and got the following result
select
keys_per_leaf, count(*) blocks
from (
select sys_op_lbid (154813, 'L', jus.rowid) block_id,
count (*) keys_per_leaf
from xxx_table jus
where jus.id is not null
or jus.dat is not null
group by sys_op_lbid (154813, 'L', jus.rowid)
group by keys_per_leaf
order by keys_per_leaf;
keys_per_leaf blocks
1 80
2 1108
3 2816
4 3444
5 3512
6 2891
7 2579
8 2154
9 1943
10 1287
11 1222
12 1011
13 822
14 711
15 544
16 508
17 414
18 455
19 425
20 417
21 338
22 337
23 327
24 288
25 267
26 295
27 281
28 266
29 249
30 255
31 237
32 259
33 257
34 232
35 211
36 209
37 204
38 216
39 189
40 194
41 187
42 200
43 183
44 167
45 186
46 179
47 179
48 179
49 171
50 164
51 174
52 157
53 181
54 192
55 178
56 162
57 155
58 160
59 153
60 151
61 133
62 177
63 156
64 167
65 162
66 171
67 154
68 162
69 163
70 153
71 189
72 166
73 164
74 142
75 177
76 148
77 161
78 164
79 133
80 158
81 176
82 189
83 347
84 369
85 239
86 239
87 224
88 227
89 214
90 190
91 230
92 229
93 377
94 276
95 196
96 218
97 217
98 227
99 230
100 251
101 266
102 298
103 276
104 288
105 638
106 1134
107 1152
229 1
230 1 This is a 5 columns unique key index on (id number, dat date, id2 number, dat2 date type number).
Furthermore, a space analysis of this index using dbms_space.space_usage gives the following picture
Number of blocks with at least 0 to 25% free space = 0 -------> total bytes = 0
Number of blocks with at least 25-50% free space = 75 -------> total bytes = ,5859375
Number of Blocks with with at least 50 to 75% free space = 0 -------> Total Bytes = 0
number of blocks with at least 75 to 100% free space = 0 -------> total bytes = 0
Number of full blocks with no free space = 99848 -------> total bytes = 780,0625
Total blocks ______________________________
99923
Total size MB______________________________
799,384It seems for me that this index needs to be either coalesced or compressed.
Then, what would be the best option in your opinion?
Thanks in advance
Mohamed Houri
Edited by: Mohamed Houri on 12-janv.-2011 1:18So let me continue my case
I first compressed the index as follows
alter index my_index rebuild compress 2;which immediately presents two new situations
(a) index space
Number of blocks with at least 0 to 25% free space = 0 -------> total bytes = 0
Number of blocks with at least 25-50% free space = 40 -------> total bytes =, 3125
Number of Blocks with at least 50 to 75% free space = 0 -------> total Bytes = 0
Number of blocks with at least 75 to 100% free space = 0 -------> total bytes = 0
Number of full blocks with no free space = 32361 -------> total bytes = 252, 8203125
Total blocks ______________________________
32401
Total size Mb______________________________
259,208meaning that the compress command freed up 67487 leaf blocks and reduced the size of the index from to 799,384 MB to 259,208 MB.
It also shows a relative nice pictue of number of keys per leaf block (when compared to the previous situation)
(b) on the number of key per leaf block
KEYS_PER_LEAF BLOCKS
4 1
6 1
13 1
15 1
25 1
62 1
63 1
88 1
97 1
122 1
123 3
124 6
125 4
126 2
289 4489
290 3887
291 3129
292 2273
293 1528
294 913
295 442
296 152
297 50
298 7
299 1 In a second step, I have coalesced the index as follows
alter index my_index coalesce;which produces the new figure
Number of blocks with at least 0 to 25% free space = 0 -------> total bytes = 0
Number of blocks with at least 25-50% free space = 298 -------> total bytes = 2,328125
Number of Blocks with at least 50 to 75% free space = 0 -------> Total Bytes = 0
Number of blocks with at least 75 to 100% free space = 0 -------> total bytes = 0
Number of full blocks with no free space = 32375 -------> total bytes = 252, 9296875
Total blocks ______________________________
32673
Total size MB______________________________
261,384meaning the the coalesce command has made
(a) 298-40 = 258 new blocks with 25-50% of free space
(b) 32375-32361 = 14 new additional blocks which have been made full
(c) The size of the index increased by 2,176MB (261,384-259,208)
While the number of key per leaf block keeps in the same situation
KEYS_PER_LEAF BLOCKS
4 2
5 3
9 1
10 2
12 1
13 1
19 1
31 1
37 1
61 1
63 1
73 1
85 1
88 1
122 1
123 4
124 4
125 3
126 1
289 4492
290 3887
291 3125
292 2273
293 1525
294 913
295 441
296 152
297 50
298 7
299 1 Could you please through some light on the difference between the compress and the coalesce on the effect they have made on
(a) the number of keys per leaf blocks within my index
(b) the space and size of my index?
Best regards
Mohamed Houri -
When displaying just One WDiView in the Portal what is the best practice?
Hi,
I´m configuring some Roles to display WebDynpro iViews and I´m concerned because when a page has to display just one iView I don´t create the Page but instead I call the iView directly into the Role and the Displayed iView is viewed correctly, my concern began cause I´m checking SAP standard roles, WDiviews and WDPages and eventhough there is just one WDiView to be displayed a WDPage is been created to display it and the WD page id assigned to the Role.
Does anyone knows what is the best practice in this case?
Thanx in Advanced and Kind Regards,
Gerardo Jthere is no harm in assigning iview directly to a role but usually assigning to a page ,page to a workset and workset to a role is followed universally
-
Appl. Hierarchy and Package Hierarchy - what is the Best practice ?
Hi!
We plan to create a Package Hierarchy in our system, but then come to think of the Application Hierachy is built the way we think of building the Package Hierarchy. We planned to build a Main package called fex. HR and below a structure package called HR-PA and below that ordinary packages within that area. But should we rather create our own application hierarchy for this?
Or should we assign the packages to Sap standard application Hierarchy in the HR area ?
What is the Best practice in this area ? Have any tried to create their own hierarchies ?
Regards, TineHi!
You can create your own Application Hierarchy as well .
From ABAP Workbench select Overview->Applic. hierarchy->SAP or Customer
This is what SAP says about this :
<i>The application component hierarchy is a method of splitting up the SAP System from a logical or <b>business</b> point of view. Packages are a method of modularizing the system from a <b>technical</b> point of view. This technical modularization can, but need not, match the logical division of the system. Assignments should be made however between these two views.</i>
Regards, Tine -
What is the best practice for changing view states?
I have a component with two Pie Charts that display
percentages at two specific dates (think start and end values).
But, I have three views: Start Value only, End Value only, or show
Both. I am using a ToggleButtonBar to control the display. What is
the best practice for changing this kind of view state? Right now
(since this code was inherited), the view states are changed in an
ActionScript function which sets the visible and includeInLayout
properties on each Pie Chart based on the selectedIndex of the
ToggleButtonBar, but, this just doesn't seem like the best way to
do this - not very dynamic. I'd like to be able to change the state
based on the name of the selectedItem, in case the order of the
ToggleButtons changes, and since I am storing the name of the
selectedItem for future reference.
Would using States be better? If so, what would be the best
way to implement this?
Thanks.I would stick with non-states, as I have always heard that
states are more for smaller components that need to change under
certain conditions, like a login screen that changes if the user
needs to register.
That said, if the UI of what you are dealing with is not
overly complex, and if it will not become overly complex, maybe
states is the way to go.
Looking at your code, I don't think you'll save much in terms
of lines of code. -
What is the best practice for full browser video to achieve the highest quality?
I'd like to get your thoughts on the best way to deliver full-browser (scale to the size of the browser window) video. I'm skilled in the creation of the content but learning to make the most out of Flash CS5 and would love to hear what you would suggest.
Most of the tutorials I can find on full browser/scalable video are for earlier versions of Flash; what is the best practice today? Best resolution/format for the video?
If there is an Adobe guide to this I'm happy to eat humble pie if someone can redirect me to it; I'm using CS5 Production Premium.
I like the full screen video effect they have on the "Sounds of pertussis" web-site; this is exactly what I'm trying to create but I'm not sure what is the best way to approach it - any hints/tips you can offer would be great?
Thanks in advance!Use the little squares over your video to mask the quality. Sounds of Pertussis is not full screen video, but rather full stage. Which is easier to work with since all the controls and other assets stay on screen. You set up your html file to allow full screen. Then bring in your video (netstream or flvPlayback component) and scale that to the full size of your stage (since in this case it's basically the background) . I made a quickie demo here. (The video is from a cheapo SD consumer camera, so pretty poor quality to start.)
In AS3 is would look something like
import flash.display.Loader;
import flash.net.URLRequest;
import flash.display.Bitmap;
import flash.display.BitmapData;
import flash.ui.Mouse;
import flash.events.Event;
import flash.events.MouseEvent;
import flash.display.StageDisplayState;
stage.align = StageAlign.TOP_LEFT;
stage.scaleMode = StageScaleMode.NO_SCALE;
// determine current stage size
var sw:int = int(stage.stageWidth);
var sh:int = int(stage.stageHeight);
// load video
var nc:NetConnection = new NetConnection();
nc.connect(null);
var ns:NetStream = new NetStream(nc);
var vid:Video = new Video(656, 480); // size off video
this.addChildAt(vid, 0);
vid.attachNetStream(ns);
//path to your video_file
ns.play("content/GS.f4v");
var netClient:Object = new Object();
ns.client = netClient;
// add listener for resizing of the stage so we can scale our assets
stage.addEventListener(Event.RESIZE, resizeHandler);
stage.dispatchEvent(new Event(Event.RESIZE));
function resizeHandler(e:Event = null):void
// determine current stage size
var sw:int = stage.stageWidth;
var sh:int = stage.stageHeight;
// scale video size depending on stage size
vid.width = sw;
vid.height = sh;
// Don't scale video smaller than certain size
if (vid.height < 480)
vid.height = 480;
if (vid.width < 656)
vid.width = 656;
// choose the smaller scale property (x or y) and match the other to it so the size is proportional;
(vid.scaleX > vid.scaleY) ? vid.scaleY = vid.scaleX : vid.scaleX = vid.scaleY;
// add event listener for full screen button
fullScreenStage_mc.buttonMode = true;
fullScreenStage_mc.mouseChildren = false;
fullScreenStage_mc.addEventListener(MouseEvent.CLICK, goFullStage, false, 0, true);
function goFullStage(event:MouseEvent):void
//vid.fullScreenTakeOver = false; // keeps flvPlayer component from becoming full screen if you use it instead
if (stage.displayState == StageDisplayState.NORMAL)
stage.displayState=StageDisplayState.FULL_SCREEN;
else
stage.displayState=StageDisplayState.NORMAL; -
What is the best practice for voicemail migration?
Hello Tech Gurus,
Am looking into a way to migrate our customer voicemail where their voicemail is on NME-CUE module. They want to migrate their voicemail's configurations, licenses and related (to SRE module) and I would like to know what is the best practice or guidelines that I can refer to.
Thank you very much!
Regards,
Alex.Hi Alex,
I was seeing the DOC which says that
Cisco supports transfer of CUE licenses, with some restrictions. Transfer is supported for CUE devices that are of the same type, for an RMA or in cases in which a license was wrongly installed. This process is not intended for transferring licenses from one generation to another (for example, from NM-CUE to NME-CUE, or from NME-CUE to SRE devices). Transferring a license is accomplished using a process called rehosting. The rehosting process transfers a license from one UDI to another by revoking the license from the source device and installing in a new device
http://www.cisco.com/c/en/us/td/docs/voice_ip_comm/unity_exp/rel7_1/Licensing/CUELicensing_book/csa_overview_CUE.html#wp1101175
You can still speak to licensing team along with show license udi from SRE module along with old licenses details from NME-CUE fro rehosting.
regds,
aman -
What are the best practices to connect 30-40 iPads to Wi-Fi in a single room?
What are the best practices to connect 30-40 iPads to Wi-Fi in a single room?
I don't use it but it does say this in the help section...
-
What are the best practices to migrate VPN users for Inter forest mgration?
What are the best practices to migrate VPN users for Inter forest mgration?
It depends on a various factors. There is no "generic" solution or best practice recommendation. Which migration tool are you planning to use?
Quest (QMM) has a VPN migration solution/tool.
ADMT - you can develop your own service based solution if required. I believe it was mentioned in my blog post.
Santhosh Sivarajan | Houston, TX | www.sivarajan.com
ITIL,MCITP,MCTS,MCSE (W2K3/W2K/NT4),MCSA(W2K3/W2K/MSG),Network+,CCNA
Windows Server 2012 Book - Migrating from 2008 to Windows Server 2012
Blogs: Blogs
Twitter: Twitter
LinkedIn: LinkedIn
Facebook: Facebook
Microsoft Virtual Academy:
Microsoft Virtual Academy
This posting is provided AS IS with no warranties, and confers no rights. -
What is the best practice in securing deployed source files
hi guys,
Just yesterday, I developed a simple image cropper using ajax
and flash. After compiling the package, I notice the
package/installer delivers the same exact source files as in
developed to the installed folder.
This doesnt concern me much at first, but coming to think of
it. This question keeps coming out of my head.
"What is the best practice in securing deployed source
files?"
How do we secure application installed source files from
being tampered. Especially, when it comes to tampering of the
source files after it's been installed. E.g. modifying spraydata.js
files for example can be done easily with an editor.Hi,
You could compute a SHA or MD5 hash of your source files on
first run and save these hashes to EncryptedLocalStore.
On startup, recompute and verify. (This, of course, fails to
address when the main app's swf / swc / html itself is
decompiled) -
My final data table contains a two key columns unique key constraint. I insert data into this table from a daily capture table (which also contains the two columns that make up the key in the final data table but are not constrained
(not unique) in the daily capture table). I don't want to insert rows from daily capture which already exists in final data table (based on the two key columns). Currently, what I do is to select * into a #temp table from the join
of daily capture and final data tables on these two key columns. Then I delete the rows in the daily capture table which match the #temp table. Then I insert the remaining rows from daily capture into the final data table.
Would it be possible to simplify this process by using an Instead Of trigger in the final table and just insert directly from the daily capture table? How would this look?
What is the best practice for inserting unique (new) rows and ignoring duplicate rows (rows that already exist in both the daily capture and final data tables) in my particular operation?
Rich PPlease follow basic Netiquette and post the DDL we need to answer this. Follow industry and ANSI/ISO standards in your data. You should follow ISO-11179 rules for naming data elements. You should follow ISO-8601 rules for displaying temporal data. We need
to know the data types, keys and constraints on the table. Avoid dialect in favor of ANSI/ISO Standard SQL. And you need to read and download the PDF for:
https://www.simple-talk.com/books/sql-books/119-sql-code-smells/
>> My final data table contains a two key columns unique key constraint. [unh? one two-column key or two one column keys? Sure wish you posted DDL] I insert data into this table from a daily capture table (which also contains the two columns that make
up the key in the final data table but are not constrained (not unique) in the daily capture table). <<
Then the "capture table" is not a table at all! Remember the fist day of your RDBMS class? A table has to have a key. You need to fix this error. What ETL tool do you use?
>> I don't want to insert rows from daily capture which already exists in final data table (based on the two key columns). <<
MERGE statement; Google it. And do not use temp tables.
--CELKO-- Books in Celko Series for Morgan-Kaufmann Publishing: Analytics and OLAP in SQL / Data and Databases: Concepts in Practice Data / Measurements and Standards in SQL SQL for Smarties / SQL Programming Style / SQL Puzzles and Answers / Thinking
in Sets / Trees and Hierarchies in SQL -
What is the best practice to display info of completed task in process flow
Hi all,
I'm starting to study BPM modeling with CE7.1 EHP1. Thanks to the tutorial and example on SDN site and I can easily build my own process in NWDS and deploy to server, start it, finish it.
I like the new runtime which can show a BPMN diagram to the processors. However, I can't find a way to let the follow up processor to review the task result completed in previous step. I'm more familiar with Guided Procedure, and know there is "Display Callable Object" which can used to show some info of a completed task when the processor/owner/admin/overseer click on a completed task. Where is the feature in BPM ? What is the best practice to show such task information in BPM environment.
For example, A multiple level approval process, the higher level approver need to know the comment written by the previous approver. Can he read this information from process flow ?
I think it is very important feature for a BPM platform. In Guided Procedure, such requirement can be done with Display Callable Object + View Permission, and you just need some coding for the UI. If BPM is superior to GP, I think there must be a way to achieve this, I just do not know how ?
Can anyone shed me some light on it ?Oliver,
Thanks for your quick reply.
Yes, Notes and Attachment CAN BE USED for the purpose. But I'm still looking for a more elegant solution.
With the solution of using Notes/Attachment, the processor need to give input at two places : the task UI and Note/Attach , with similar or same data. It is really annoying.
Is there any SAP BPM real-world deployment ? None of customer has the requirement ? -
What is the Best practice for ceramic industry?
Dear All;
i would like to ask two questions:
1- which manufacturing category (process or discrete) fit ceramic industry?
2- what is the Best practice for ceramic industry?
please note from the below link
[https://websmp103.sap-ag.de/~form/sapnet?_FRAME=CONTAINER&_OBJECT=011000358700000409682008E ]
i recognized that ceramic industry is under category called building material which in turn under mill product and mining
but there is no best practices for building material or even mill product and only fabricated meta and mining best practices is available.
thanks in advanceHi,
I understand that you refer to production of ceramic tiles. The solution for PP was process, with these setps: raw materials preparation (glazes and frits), dry pressing (I don't know extrusion process), glazing, firing (single fire), sorting and packing. In Spain, usually are All-in-one solutions (R/3 o ECC solutions). Perhaps the production of decors have fast firing and additional processes.
In my opinion, the curiosity is in batch determination in SD, that you must determine in sales order because builders want that the order will be homogeneus in tone and caliber, and he/she can split the order in diferents deliveries. You must think that batch is tone (diferents colours in firing and so on) and in caliber.
I hope this helps you
Regards,
Eduardo
Maybe you are looking for
-
Hi! Could You help me resolve the problem with passing on object value from one class to another one. To clearing the situation I'll give You an example: I' ve got three classes: classOne (with main method), classTwo, classThree public class classOne
-
Need to call user defined table in Report
Hi there, In my report, need to call user defined database table. This table contains 2 columns one for checkbox. After calling this table, user has to check required rows and save changes. can we create transaction code for this table and call from
-
Any description on how to use the Text Editor used for this Forum?
I am very frustrated when trying to use the text Editing functions (without use of HTML, that I do not undertstand) that can be used to create Posts in this Forum . Can somebody point me to a good description of the Text Editor used to enter/edit Pos
-
Unable to see pictures in picture folder
Can see via explore but when new pictures are added they are not visible in picture folder - only advice seems to be reboot!!
-
Hi, I want to configure the smtp in cisco prime for receive alarm message in my account .than ,when i press the test button ,the following message is display. Failed to send mail to primary SMTP server. Please make sure that you save mail configurati