Best practice OOP - good design

I started to write a chat application [server + client]
and I wanted to optimise it [good OOP + reuse of classes,objects].
So, I have a class that handles the interface, a class that handles the socket [reading, writing], a class that handles the events, etc...
As Iwanted to write it the best way possible, I looked a little in patterns and OOP design books in order to make it better.
After reading, digging ..., an idea came to me.
A problem I came across many times, in my past projects also was the fact that, when I was in the interface class, and i needed the socket class I couldn't find a way to get it and instantiate it when I needed it. I always had to pass it as an argument to the constructor of the interface class [just for this example] or in the class where i instantiate the interface class, i had to appeal a method on the object=interface in order to put the socket object in the interface class , for future manipulation.
It could get more complicated if i wanted to use the socket object only when a certain event appear, and i wanted it in who-knows what class.
So i trid this implementation of noname pattern [with influences from all the books I read] :
I create an instatiator of objects [say class ObjectManager] with the following methods:
void addObject(Object o,String nameObj)
Object getObject(String nameObj)
Now I instantiate [in the meanwhile i present to the user a pretty JWindow with loading...] all the objects I will use in the application and the objects-resource > [Colors, Fonts,etc...] and also add them to the ObjectManager.Also, all the objects will have a reference to this ObjectManager.
and when I need a specific Object, I will get it with [specyfing its name]
ObjectManager.getObject(nameObj).
What I want from the guys from this forum:
1) comments on this [is it good, i just go crazy, all of this is garbage, i am wrong(specify why)]...
2) Is this a well-known pattern, or a version of a well-known pattern and I can't recognize it?
3) If anybody understood my problem, is this the best way to achieve it[getting objects already instantiated whenever and wherever I want], and if not, which is it
4) The problem is put wrong, an application should be thought differently - please guide me to some URLs, tutorials...
Thanx in advance
Gabi

In some ways, this is similar to a Factory pattern: a place that you go to get objects.
The difference is that a typical Factory creates (or returns from somewhere!) objects of a limited number of related types, based on some configuration input (a FooFactory, for example, doesn't typically return a Bar object, unless Bar is a subclass of or implements Foo).
For an atypical factory, consider the java.rmi.Naming class. On the one side, a server registers the objects that it serves; on the other, a client requests those objects. As far as the client is concerned, this fits the Factory pattern exactly; on the server side, it doesn't.
Personally, I like having a singleton "Manager" object for various semi-related objects within an application. For example, a DialogManager that holds onto all the application's dialogs. Someone has to know about them, and it could be the application's main class, but that tends to more clutter than I like.

Similar Messages

  • Best Practice For Cube Design

    All,
    First post here and was wondering if anyone out there has a best practice for cube design or optimisation. Currently have 7 Cubes that have been populated for the last 6 months and am now looking at ways of speeding up their population.
    Are there any hard and fast rules about dimensions?
    Should they be kept to a percentage of the fact table?
    When should line item dimensions be used?
    Regards
    Gary Boyle

    Hi Gary,
    Ideally the DIM tables should be 20% of the fact table and preferably less. You can check the size ratios in RSRV using the Database tables test > Database info about InfoProvider tables. Line items dimensions should be employed where the char has a large number of unique values (like 0MATERIAL, or 0CUSTOMER), so that anothe DIM ID is not created, but the SID values are used directly in the Fact Table.
    See these for more:
    https://www.sdn.sap.com/irj/servlet/prt/portal/prtroot/docs/media/uuid/10b589ad-0701-0010-0299-e5c282b7aaad
    https://www.sdn.sap.com/irj/servlet/prt/portal/prtroot/docs/library/uuid/08f1b622-0c01-0010-618c-cb41e12c72be
    https://www.sdn.sap.com/irj/servlet/prt/portal/prtroot/docs/library/uuid/6ce7b0a4-0b01-0010-52ac-a6e813c35a84
    Hope this helps...

  • Best Practices For Dashboard design  through BI

    Hi
      If I want to create a dashboard through BI7 .what is the best way to suggest the client people. Which way SAP recommended for BI7 Best practices for dashboard design.
    Thanks & Regards,
    Praveen

    Sloved

  • Best practice for GSS design

    Please advice as to what records needs to go in Public DNS server in a scenario where i have url say x.y.com which is listed in the Domain List of the GSS-P, sot that GSS-P or GSS-S can handout the respective external VIP to the clients requesting the url in case one of the GSS/site (GSS_P and GSS-S) goes unavailable
    Please also specify the communication path of a client accessing x.y.com.
    Advice the best practice
    Thanks in advance
    ~EM

    Hi,
    I am new to GSS. I would appreciate if some can help me with the deisgn. I want to know if I need to put the GSS inline after the inernet facing firewall and befor the ACE module. OR use it as one arm mode. Trying to figure out the best fit in the design.
    FWSM1 >>> GSS >>> ACE
    or
    just put the GSS as one arm mode between the FWSM1 >>> ACE
                                                                                                         |
                                                                                                    GSS
    Thanks in advance,
    Nav

  • What are the best practice in report design ?

    Hi,
    According to you, what are the best practices in report desing about layout, fonts and colors ?
    Thks

    Hi,
    It all depends that what type of report you are designing and what tool you are using - WebI or Crystal.
    And in WebI, if it is cross tab or Tabular report etc.
    One most important thing is that what is client requirement. May be client does not like which is best practice.
    On the base of my personal experience I will create few demo reports using different options - layout, colors and fonts and show them to client so that they may decide.
    Regards,
    Bashir Awan

  • Best Practice / Standards to design a Scorecard in PL-SQL

    I am attempting to put together a Scorecard for my client who wants to track set of employees with different job role and title. Basically he identified several cetegories, criteria under those categories that he wants to score them by set weightages
    Example
    Category 1
    Productivity
    Category Weightage
    80%
    Criteria
    WorkTypeA Weightage 25%
    WorkTypeB Weightage 25%
    WorkTypeB Weightage 25%
    WorkTypeB Weightage 25%
    Category 2
    Quality
    Category Weightage
    20%
    Criteria
    Quality Type 1 50%
    Quality Type 2 50%
    He wants to rank each employee and rate then on a scale of 1 to 5, 1 being best. He also wants to rank by Role and Title as well
    My question...is there a standard methodology/template to design this in pl-sql? I can put something together but I have a feeling there should be existing best practice on this kind of scorecard design. Any ideas?
    Buzzer
    Message was edited by:
    vinny75

    Hi
    Thanks for the response. I dont have any model yet. All I have at this time, is a set of main categories, criteria under the category, weightage at the category level and criteria level. The Criteria they want to weigh on, is located in the datamart.
    I guess I could build a pl-sql packaged routine using the Analytic functions and start building snapshot tables holding the score.
    Is this how scorecard work is done?

  • Any best practices on workflow design??

    I feel difficult when migrating applications from DEV->TEST->PROD.
           This is because I have created web services in .net.
           So, for each migration, I am suppose to change all the WSDL links in all forms and Workflows.
           Currently:
              I do open the processes in notepad replace all wsdl connection with TEST/PROD connections.
              I do open each form and goto XML Source and replace all WSDl strings.
            Is there any other best practice(s) to do that?
    Nith

    I followed a different approach for one of my project as:
    created several form variables which hold the WSDL for each different servers.
    Calling the web service from javascript code (instead of data connections).
    This solves the problem but increases the development overhead.
    http://groups.google.com/group/livecycle/web/form%20variables.PNG
    Another way is to design all your web services within adobe itself. In this case we will have the same host name (localhost) forever which doesn't require any modification throughout its lifetime.
    Nith

  • PI best practice and integration design ...

    Im currently on a site that has multiple PI instance's for each region and the question of inter-region integration has been raised my initial impression is that each PI will be in charge of integration of communications for its reginal landscape and inter-region communications will be conducted through PI - PI interface . I havent come across any best practice in this regard and have never been involved with a multiple PI landscape ...
    Any thoughts ? or links to best practice for this kind of landscape ?...
    to Summaries
    I think this is the best way to set it up, although numerous other combinations are possible, this seems to be the best way to avoid any signifcant system coupling. When talking about ECC - ECC inter-region communications
    AUS ECC -
    > AUS PI -
    > USA PI -
    > USA ECC

    abhishek salvi wrote:
    I need to get data from my local ECC to USA ECC, do i send the data to their PI/my PI/directly to their ECC, all will work, all are
    valid
    If LocalECC --> onePI --> USA ECC is valid, then you dont have to go for other PI in between...why to increase the processing time....and it seems to be a good option to bet on.
    The issue is
    1. Which PI system should any given peice of data be routed through and how do you manage the subsequent spider web of interfaces resulting from PI AUS talking to ECC US, ECC AU, BI US, BI AU and the reverse for the PI USA system.
    2. Increased processing time Integration Engine - Integration Engine should be minimal and it will mean a consistent set of interfaces for support and debug, not to mention the simplification of SLD contents in each PI system.
    I tend to think of like network routing, the PI system is the default gateway for any data not bound for a local systems you send and let PI figure out what the next step is.
    abhishek salvi wrote:
    But then what about this statement (is it a restriction or business requirement)
    Presently the directive is that each PI will manage communications with its own landscape only respectively
    When talking multiple landscapes dev / test / qa / prod, each landscape has its own PI system generally, this is an extention of the same idea except that both systems are productive, from a interface and customisation point of view given the geographical remotness of each system local interface development for local systems and support makes sense, whilst not limited to this kind of interaction typically interfaces for a given business function for a given location (location specific logic) would be developed in concert with the interface and as such has no real place on the remote system (PI).
    To answer your question there is no rule, it just makes sense.

  • Best practices for network design on WLC 2504 and 5508

    Dear all:
    I'm looking for some recommendations on WLC 2504 and 5508 about the the following:
    Maximum amount of AP per port
    The scenario when to use all ports in both WLC
    Maximum number of clients(users) per port
    Bandwidth comsumption of  management vs data in order to assign one port for management
    I've just found this:
    Cisco 5508 controllers have eight Gigabit Ethernet distribution system ports, through which the controller can manage multiple access points. The 5508-12, 5508-25, 5508-50, 5508-100, and 5508-250 models allow a total of 12, 25, 50, 100, or 250 access points to join the controller. Cisco 5508 controllers have no restrictions on the number of access points per port. However, Cisco recommends using link aggregation (LAG) or configuring dynamic AP-manager interfaces on each Gigabit Ethernet port to automatically balance the load. If more than 100 access points are connected to the 5500 series controller, make sure that more than one gigabit Ethernet interface is connected to the upstream switch.
    http://www.cisco.com/c/en/us/td/docs/wireless/controller/6-0/configuration/guide/Controller60CG/c60mint.html
    Thanks for your help.

    The 5508-12, 5508-25, 5508-50, 5508-100, and 5508-250 models allow a total of 12, 25, 50, 100, or 250 access points to join the controller.
    This is an old document.  5508 can now support up to 500 APs if you run firmware 7.X.  2504 can support up to 75 APs if you run firmware 7.4.X.
    I'm looking for some recommendations on WLC 2504 and 5508 about the the following:
    Best practice and recommendation is to LAG all ports so you will be able to form a link redundancy.  If one link goes down, you have other link to push traffic. 

  • Best practice or good pattern for developing complex swing UI

    When I develop some a bit complex swing UI which maybe contain many labels, fields etc. my code becomes massive. Especially when I use GridbagLayout, when there are many components on a panel, if I want to add or remove or change one component's position sometimes I need to modify many x, y to adjust. Are there any good pattern or solution for dealing with this? Should I write my own layout? Or to find a UI designer Plugin in eclipse (but I feel the codes generated by designer are usually hard to maintain)? Thanks.

    I've recently been working with GridBagLayout. My current solution for working with this layout is to, whenever possible, create a panel builder class that builds the panel. This only works well, however, if your panel layout can be described in a generic fashion.
    For example, I have a particular layout I want to use that consists of headers that can span the entire width of a panel with sections between the headers that consist of two roughly centered columns such that each section has the same center line between the columns. I can accomplish this with GridBagLayout. So I wrote a panel builder with methods addHeader(Component) and addRow(leftComponent, rightComponent), a few other helper methods, and behind the scenes, it prepares it all using a GridBagLayout.
    Sort of like this:
    MyPanelBuilder builder = new MyPanelBuilder();
    builder.addHeading("Section 1");
    builder.addRow(fooPanel, barPanel);
    builder.addHeading("Section 2");
    builder.addRow(aPanel, bPanel);
    builder.addRow(cPanel, dPanel);
    JPanel myPanel = builder.build();Behind the scenes, the panel builder keeps a list of everything it needs to add to the panel. Then when build is called, it lays it all out in a panel using GridBagLayout and returns it.
    As for extending JFrame for your main application frame and JPanel for specific purpose application panels, I'm still not convinced it's a bad idea.

  • GUI Design Best Practices

    Still learning Java and OOP. The question is, what is the best practice method for designing the user interface? For instance, I have a main_GUI that has all the basic stuff and then I need to have 5 or so different displays. A couple of them need to be modal so I'm creating those as jDialog. Is this correct or should you not use those.
    Actually, all of the additional screens I want to be modal so I don't see another way of creating a normal jFrame that is modal which is why I'm asking before creating every screen as a jDialog.
    Also, I have one screen that could have 3 different functions. Is it acceptable to create the screen with all of the components and just hide the ones that I don't need at any given time or should I actually create 3 different screens that all look roughly the same?
    Thanks for any input/advice.

    ShosMeister wrote:
    So what's the difference, or more importantly, what's wrong with using jFrames? If you are creating a stand-alone, non-web app, then you will of course create a JFrame, and place your app in it, but I'm suggesting that the app not extend JFrame but rather you simply create a JFrame when you need it, and place a JPanel in this JFrame's contentPane, pack it and display it. The reasons for not extending a JFrame are multiple but mostly boil down to a general preference to avoiding extending classes with inheritance and using instead composition. There are many blogs dedicated to discussing this paradigm which can be found with Google, and here are two decent articles from the first page of my search:
    [JavaWorld: Inheritance versus composition: Which one should you choose?|http://www.javaworld.com/javaworld/jw-11-1998/jw-11-techniques.html]
    [Object Composition vs. Inheritance|http://brighton.ncsa.uiuc.edu/~prajlich/T/node14.html]
    One error caused by extension of a Swing class via inheritance that I saw in a recent thread in the Swing forum involved a class that overrode JLabel and held x and y int variables. The class had setX(int i), setY(int i), and getX(), getY() methods and thereby unknowingly overrode JComponents own similar methods completely messing up the JLabels ability to be positioned correctly.
    Are you saying I should only have one "window" and swap the data constantly in that window? Nope. I am saying that you should emulate other windows-like programs that you use. Most use a combination of panel swapping, modal and non-modal dialogs, ... whatever works best for the situation. But most importantly, you should write your code so that it is easy to change from one to the other with a minimal change in your code. Aim for flexibility of use.
    Would that require that all the jPanels were the same size to be able to display correctly?If you swapped with a CardLayout and created your JPanels to be flexible with sizing, the CardLayout would take care of this mostly for you.
    So if I create a main jPanel, set it up with all of the components that I want, when I run the program and main() is called, it would create the jFrame and drop the jPanel into itself? Not sure I've seen any examples of that so I'll have to look that one up. Yes, you'd drop the JPanel into the JFrame's contentPane. There are plenty of examples here, but it may take some digging to find them.
    Unless of course I've completely misunderstood you which is possible since, as I've mentioned, I'm just learning Java.I think you are understanding what we suggest here. You are asking the right questions, so I predict that you should learn Java quickly.
    Thanks!!!!Welcome!

  • Best practice game design

    Having decided to use java to develop what will be for the most part a 2D (overhead) tile-based RPG game I'm wondering what the best practice is for designing a game like this.
    At the minute I'm intending on using a 'state' system, varying game states (main game, shop, battle, world map etc., state transitions and single use states to create further immersion in the game) implement a State interface that defines how the main game engine interacts with the state (mainly a tick method called on each game loop). When the program wants to switch the game state it makes a call to the main engine, something like setState(State).
    Has anyone written an RPG along these lines? What kind of memory usage did you have, and did you encounter any problems along the way with this design?

    So far, I've identified two perspectives.
    The first is to consider yourself as a sort of "overmind" that tracks each object within the game as a seperate entity. The primary advantage seems to be that it is trivial to add objects as you go along. The primary disadvantage is dealing with all the message passing.
    For example, say you are fighting a horde of goblins when a dragon flies overhead and breathes fire on the battlefield. You would have to call each goblin instance, and have that particular goblin check to see if it dies, and if so, call its death routine. You would have to call your own player object, and have it check to see if you are carrying potions. Each potion then would have to check to see if it boils and explodes in reaction to the dragon breath. And so on. But it would be trivial to add an orc to the battle, or change the dragon into an evil wizard.
    This consumes quite a bit of memory (for all the objects and references), and it can be a little tricky incorporating it into the game loop.
    The other aspect is to code the player as the "center of the universe" and everything happens with respect to that player. It becomes easier find relevant objects and interact with them, but it becomes much harder to just drop an object in place.
    Using the prior example, the dragon becomes your combatant. Damage is done to a goblin in the array and it dies. The next enemy in your array dies. Do so much damage to your inventory and remove them as appropriate. Keeping track of what's going on appears to be much more straightforward, but it would be harder to add the evil wizard to the mix.
    This consumes less memory - the game is only worried about things that happen around you as opposed to well... a whole bunch of "entities" at the same time, and is significantly faster and easier to add to the game loop.
    State machines tend to follow this approach, event driven games tend to follow the prior approach.
    Obviously, I don't code games for a living. I would think that most games these days are somewhat of a mish-mash. Use a basic state machine as in the FF7 example to keep track of broad activities, and within each activity, let the objects manage themselves in response to events.
    For example, each game tick could switch among movement activities, "peaceful magic" activities, battle activities, clean up activities (such as death and xp rewards), and finally general inventory and shop activities, skipping steps as appropriate.
    And say within the movement event, you could have an monster object scream and add itself to the battle mode queue if it detects your player object within such and such a distance.
    Anyway, I've been toying with the idea of coding or volunteernig to work on an RPG as well, so I'd be interested in hearing from you guys on how to organize things too.

  • Questions VLAN design best practices

    As per best practices for VLAN design:
    1) Avoid using VLAN 1 as the “blackhole” for all unused ports.
    2) In the local VLANs model, avoid VTP (use transparent mode).
    Point 1
    In a big network, I'm having VLAN 1 as the blackhole VLAN. I'd like to confirm that, even if we're not complying with best practices, we're still doing fine.
    a) all trunk ports on all switches have the allowed vlans explicitly assigned.
    b) about all ports on all switches are assigned to specific data/voice vlans, even if shutted down
    c) the remaining ports (some unused sfp ports for example) are shutted down
    d) we always tag the native vlan (vlan dot1q tag native)
    So, no data is flowing anywhere on VLAN 1. In our situation, it is safe to use VLAN 1 as blackhole VLAN?
    Point 2
    Event if we're using local VLANs model, we have VTP in place. What are the reasons of the best practice? As already said, we allow only specific VLANs on trunk ports (it's part of our network policy), so we do not have undesired layer 2 loops to deal with.
    Any thoughs?
    Bye
    Dario

    We are currently using VTP version 3 and migrating from Rapid-PVST to MST.
    The main reason for having VTP in place (at least for use) is to have the ability to assign ports to the correct VLAN in each site simply looking at the propagated VLAN database and to manage that database centrally.
    We also avoid using the same VLAN ID at two different sites.
    However, I did find something to look deeped: with MST and VTP, a remote switch can be root for a VLAN it doesn't even use or as active ports into, and this doesn't feel right.
    An example:
    1) switch1 and switch528 share a link with allowed vlan 100
    2) switch1 is the root for instances 0 and 1
    4) VLAN 100 is assigned to instance 1
    5) VLAN 528 is not assigned to any particular instance so it goes under instance 0
    6) VLAN 528 is the Local Data LAN for switch528 (switch501 has VLAN 501)
    swtich528#sh spanning-tree vlan 528
    MST0
      Spanning tree enabled protocol mstp
      Root ID    Priority    24576
                 Address     1c6a.7a7c.af80
                 Cost        0
                 Port        25 (GigabitEthernet1/1)
                 Hello Time   2 sec  Max Age 20 sec  Forward Delay 15 sec
      Bridge ID  Priority    32768  (priority 32768 sys-id-ext 0)
                 Address     1cde.a7f8.4380
                 Hello Time   2 sec  Max Age 20 sec  Forward Delay 15 sec
    Interface           Role Sts Cost      Prio.Nbr Type
    Gi0/1               Desg FWD 20000     128.1    P2p Bound(PVST)
    Gi0/2               Desg FWD 20000     128.2    P2p Edge
    Gi0/3               Desg FWD 200000    128.3    P2p Edge
    Gi0/4               Desg FWD 200000    128.4    P2p
    Gi0/5               Desg FWD 20000     128.5    P2p Edge
    switch1#sh spanning-tree vlan 501
    MST0
      Spanning tree enabled protocol mstp
      Root ID    Priority    24576
                 Address     1c6a.7a7c.af80
                 This bridge is the root
                 Hello Time   2 sec  Max Age 20 sec  Forward Delay 15 sec
      Bridge ID  Priority    24576  (priority 24576 sys-id-ext 0)
                 Address     1c6a.7a7c.af80
                 Hello Time   2 sec  Max Age 20 sec  Forward Delay 15 sec
    Interface           Role Sts Cost      Prio.Nbr Type
    Should I worry about this?

  • Universe Design Best Practices for Oracle

    Hello All,
    We recently moved from XIR2 on MS SQL 2005 to XI 3.1 on Oracle. This has been a difficult move for us as my team is new to oracle. I'm currently working on several performance issues between BOBJ and Oracle and am looking for documentation on best practices for universe design with oracle. I've foudn tidbits here and there regrading using parameters joing_by_sql and boundary_weight_table, wondering if there are other options out there that might help. We have queries taking 45+ minutes to run and that is totally unacceptable.
    thanks
    Andrea

    I am not sure if you are looking for Optimization or anything else. sorry for that following link might help you considering Oracle as DB.
    Link:[Universe Optimization 1|http://www.bidwtoday.com/business-objects/universe-designer/business-objects-universe-optimization/]
    Link:[Universe Optimization 2|http://forums.sdn.sap.com/post!reply.jspa?messageID=8721932]
    --Kuldeep

  • Best practices or design framework for designing processes in OSB(11g)

    Hi all,
    We have been working in oracle 10g, now in the new project we are going to use Soa suite 11g.For 10g we designed our services very similar to AIA framework. But in 11g since OSB is introduced we are not able to exactly fit the AIA framework here because OSB has a structure different than ESB.
    Can anybody suggest best practices or some design framework for designing processes in OSB or 11g SOA Suite ?

    http://download.oracle.com/docs/cd/E12839_01/integration.1111/e10223/04_osb.htm
    http://www.oracle.com/technology/products/integration/service-bus/index.html
    Regards,
    Anuj

Maybe you are looking for

  • I updated iTunes and now I cannot connect to the store

    this is what showed up when i ran the diagnostics check. i've scoured the itunes support page with no outcome so i could really use your help thanks so much Microsoft Windows XP Professional Service Pack 3 (Build 2600) HP Pavilion 061 PX721AA-ABA M71

  • When 40 subreports are added programmatically to a report the last subreport to be added is shown first while all other reports are in the correct order

    I am loading multiple sub-reports (up to 40) into a master report document using the Crystal SDK. This is accomplished by obtaining a reference to the detail area, adding a section to it, and then importing the subreport into the detail area. The mas

  • Publish options stay grey?

    Hi, I successfully launched two sites, I have built a third that is ready to launch but the publish and visit option buttons are greyed out, the same applies for the drop down menu, I also have a blue dot next to each of the first two sites in the si

  • USB driver HP Pavilion g4-1004tx

    Hai... need help, My Laptop is HP G4-100TX, could not detect any USB device, please help me what sould I do??? really realy need help on device manager, the device is yellow marked like this  . Thanks Before

  • New website broken in IE

    Can somebody look at this site in IE and almost any other browser, and recommend some First Aid for the content pages? www.gmavt.net/~powerdog Pages should look OK in other browsers, but in IE all the hidden elements are visible and moved to the wron