Design patterns concern

i am designing a graph api. i have defined interfaces for a node, arc, and graph. there are multiple interfaces defined (using inheritance) defined for each of these three interfaces.
all my implementations of these interfaces have not considered fields relevant to display on a x-y coordinate graph. now that i have coded the implementations, i am ready to display these objects.
the problem is that i have many implementations, but they now have to extend another interface for display. i find that i have to create a new class to implement the existing one and implement the new interface for each implementation.
to illustrate, i have a Node interface. there are only two methods i.e. String getId() and void setId(String id). i have two additional interfaces that extends this Node interface i.e. SimpleNode and ComplexNode (these have their own pertinent methods, not listed). I have implemented the Node interface with NodeImpl, and implemented the other 2 interfaces with SimpleNodeImpl and ComplexNodeImpl, both of which extends NodeImpl and each implementing SimpleNode and ComplexNode interfaces, respectively. at this point, i define another node interface for the purpose of drawing i.e. DrawableNode (which extends the Node interface and has getters/setters for x and y coordinate.
my problem is, how do i get SimpleNodeImpl and ComplexNodeImpl to implement the DrawableNode interface? i have considered the following approaches:
1. have SimpleNodeImpl and ComplexNodeImpl implement DrawableNode as well as what they are already implementing (i.e. SimpleNode and ComplexNode).
2. extend SimpleNodeImpl and implement DrawableNode interface i.e. DrawableSimpleNodeImpl (and likewise with ComplexNodeImpl).
3. create an implementation of DrawableNode, DrawableNodeImpl, and use composition to place type Node as a field member.
i find option #1 problematic because that means i have to define getters/setters for x and y in SimleNodeImpl and ComplexNodeImpl. this would NOT take advantage of inheritance.
i find option #2 problematic because this would mean i would have to extends all my node implementations just to have them drawable. (i actually have more than 2 extensions of nodes that i want to draw). moreover, i would also run into the problem in option #1, where i have to define getters/setters for x and y in each of these subclasses.
i am currently leaning towards option #3, but i find the relationship clumsy and even counterintuitive to myself; i plan to use the MVC design pattern, and i have calculated that this approach will result in a web of event/listener complications.
i am sure there are more options, but these are the ones that i have thought of. the goals are to keep the inheritance simple, implementations to a bare minimum, and have something that will fit nicely in with the MVC design pattern.
the general question may be: how do i design the relationships so that they will operate in the business logic layer and then be displayable on some GUI layer? is inheritance the way? or is composition the way? or is there yet another way that i have overlooked?

really long questions dont usually get answered here.

Similar Messages

  • Does any body have any design patterns of JSF Web Application Developping?

    Can any one answer me some questions?
    #1.I am an amatuar of people who develop Web Application.For some reason,We choose the JSF to develop our item.through some introduction,I know the UI component of JSF is resided in Server side,is it right?but I am a little confused that:if there are many users who are exploring our jsf website.(to simplify my question,image I had just one web page and just one button)How many UI components(buttons) will be there?How it(they?) works?
    #2.Does any body have the success experience (for example design pattern)to develop web applications?if We just concern about the Add,Delete,Modify,Query operations of some data.
    I just do my job according to my feeling.
    I will give every page a pagebean(backing bean),and I am not sure how to combine the business data with the pagebean.some one suggested that I should use delegate pattern to separate my business log and page logic.But I am still confused by following things:
    #2.1 does JSF have the same ability to help us construct the model dialog just like swing to
    help us control the operation flow?
    #2.2 If there is not,Does the following way work?I put every tabledata's property as corresponed component.if user choosed the row in the table,My Listener will syncronize the row data to the components.But
    #2.2.1 if JSF has the components according to the web users' number,how can My Listener tell which component should be update?Should I maintain the map?
    #2.2.2 If the problem I imaged above is false,Does any body can tell me how to custom      the ListDataModel,so I can use it like Swing?because now I can just use some view data to insert into ListDataModel,but after some selection operation,my business object must be find according to the selected data,it is not an interesting job!
         I am waiting for your advice!

    Ok I'll try to explain Step by step please correct me if I make any mistake because I have not played much with shared variables.
    To create a shared variable to an RT target go to the target if tou have already otherwise add an RT target by right clicking the Project>>Add targets and Devices
    Then in the target Right clikc and select the variable as shown below.
    Then once the Shared variable settings window opens Enter a variable name and then Select the type "Network Published"
    In the right side you can select the data type for the shared variable and even you can choose your custome controls.
    After selecting the data type go for the Network and select buffering if required else leave it if you are planning to use the variable just for display purpose.
    Then you can enable the RT FIFO if required (Not able to explain how it works and why it is used).
    Then after completing the Shared variable setup you can access the variable in the VI in both the Host and the RT.
    You can bind the variable to a control so that if any data from the RT is coming you can read the data from that control.
    Once you have placed your shared variable in the BD you can change the access typr to read or write depending on your need.
    This might not explain the complete shared variable concept but I believe that this would defenelty give you a kick off to start using the shared variable. Please correct or add more comments if anybody know better.
    Good luck.
    The best solution is the one you find it by yourself

  • Factory v/s Facade Design Pattern.

    Folks,
    I was just going thru the Design Patterns (Factory Pattern and the
    Facade Pattern)
    The Factory Pattern :
    The factory completely abstracts the creation and initialization of the product from the client
    This indirection enables the client to focus on its discrete role in the application without concerning itself with the details of how the product is created. Thus, as the product implementation changes over time, the client remains unchanged.
    Client--------------------->Factory----------------->Product
    The Facade Pattern
    Encapsulate the subsystem using a High-Level Interface/provides a
    simplified and uniform interface to a large subsytem of classes.
    The Client communicates with the 'Facade' which has methods to interact
    with subsystems.The Client very rarely accesses objects in the subsystems.
    Subsystems objects usually retain no knowledge of the client.
    Subsystem objects do not normally maintain any reference to Fa�ade.
    Client------------------->Facade------->Subsystems
    My Question is this:
    Arent both these pattern quite similar becos both designs access an Interface
    which inturn invokes the required object of the subsystems?
    Can anyone explain the major difference?

    Perhaps these definitions will clarify things a little for ya...
    Fa�ade
    The Fa�ade pattern simplifies access to a related set of objects by providing one object that all objects outside the set use to communicate
    with the set. This also promotes a weak coupling between the subsystem and its clients. This weak coupling allows you to vary the
    components of the subsystem without affecting the clients.
    Factory
    Centralize the assembly of resources necessary to create an object. This prevents the need to change all classes from changing when a
    Product changes and makes any change needed occur only in the Factory.

  • Is there a design pattern for splitting up files into smaller files?

    I am developing a project where I have to load very large files (upto 50 MB). Currently I am loading these files completely into (consecutive) memory. This has the advantage that I can very easily change bytes at certain locations, because I do not know the
    structure of all bytes.
    However, my intention is to also change the structure, e.g. removing/adding 'chunks'. Now I have the idea to remove the 'known' parts out of it, store them in classes with a data chunk only containing those parts and make a sort of reference list to those chunks.
    E.g.:
    Original file:
    Header
    ChunkA 1
    ChunkA 2
    Intermediate
    ChunkB 1
    Footer
    The result will be:
    ChunkA 1 and ChunkA 2 instance. ChunkB 1 instance
    'File' instance and a reference with base offsets + reference to all chunks.
    At the end I have to 'recreate' or write the original file (with changes) back.
    Is this in general a good idea or is there some design pattern helping me in this?

    50MB is not much in the modern era of 6GB+ machines. If you want to optimize memory then consider using a
    memory mapped file.
    But you mentioned making data structure changes. This is generally dangerous as you have to be concerned about things like disaster recovery. What happens if you are in the middle of saving the modified structure when the program dies? You just corrupted
    your file. A better solution is to stream the existing file using BinaryReader to read in the existing file in parts based upon the structure.  Write out the data to a new, temporary file using BinaryWriter. This may be the original data or your modifications
    depending upon need.  Once you've generated the new file replace the old file (with optional backup). So even if something catastrophic happens during saving you don't lose the original file.
    Michael Taylor
    http://blogs.msmvps.com/p3net

  • What is a design pattern?

    Howdy,
    I hear a lot of talk of deasign patterns in ABAP...
    My question is what on earth is a design pattern and why/how would it be useful?
    Any ideas anyone

    Hi Steve.
    The good point to start with design patterns is to read book "Design Patterns - Elements of Reusable Object-Oriented Software" by Erich Gamma, Richard Helm, Ralph Johnson, John Vlissides. It gives strong, consistent understanding of patterns basis with real life examples.
    Short introduction extract:
    "Christopher Alexander says, "Each pattern describes a problem which occurs over and over again in our environment, and then describes the core of the solution to that problem, in such a way that you can use this solution a million times over, without ever doing it the same way twice". Even though Alexander was talking about patterns in buildings and towns, what he says is true about object-oriented design patterns. Our solutions are expressed in terms of objects and interfaces instead of walls and doors, but at the core of both kinds of patterns is a solution to a problem in a context.
    In general, a pattern has four essential elements:
    The pattern name is a handle we can use to describe a design problem, its solutions, and consequences in a word or two. Naming a pattern immediately increases our design vocabulary. It lets us design at a higher level of abstraction. Having a vocabulary for patterns lets us talk about them with our colleagues, in our documentation, and even to ourselves. It makes it easier to think about designs and to communicate them and their trade-offs to others. Finding good names has been one of the hardest parts of developing our catalog.
    The problem describes when to apply the pattern. It explains the problem and its context. It might describe specific design problems such as how to represent algorithms as objects. It might describe class or object structures that are symptomatic of an inflexible design. Sometimes the problem will include a list of conditions that must be met before it makes sense to apply the pattern.
    The solution describes the elements that make up the design, their relationships, responsibilities, and collaborations. The solution doesn't describe a particular concrete design or implementation, because a pattern is like a template that can be applied in many different situations. Instead, the pattern provides an abstract description of a design problem and how a general arrangement of elements (classes and objects in our case) solves it.
    The consequences are the results and trade-offs of applying the pattern. Though consequences are often unvoiced when we describe design decisions, they are critical for evaluating design alternatives and for understanding the costs and benefits of applying the pattern. The consequences for software often concern space and time trade-offs. They may address language and implementation issues as well. Since reuse is often a factor in object-oriented design, the consequences of a pattern include its impact on a system's flexibility, extensibility, or portability. Listing these consequences explicitly helps you understand and evaluate them."
    Regards,
    Maxim.

  • [BOOK] What's the best book about DESIGN PATTERN

    Hi Guys,
    by experience, what's the best book for you concerning the Design Pattern in Abap. I mean :
    Quality,
    Comprehensiveness,
    Clearness,
    Amount of chapter,
    etc.
    Thank for advices.
    Rachid.

    Dear Rachid,
    This is rank 1 book, but u have learn online also. So many websites are there. example search: OO Design patterns ZEVOLVING.
    Regards,
    Abbas.

  • Design pattern for display configurable UI

    Hi,
    We have a UI requirement where a form (page) needs to display different components based on where the form is being accessed from.
    For e.g. If the form "X" is accessed from "abc" form then it has to display a dropdown and a list box. If the same form "X" is accessed from "xyz" form then it has to display one more dropdown in addition, along with the list box.
    The validations to be done on "X" form also depend on from where it accessed from.
    Can someone please guide on how should the form be designed (e.g. how should the input parameters be taken etc)? Is there any design pattern already in place which I can refer to?
    Thanks in advance.

    Can't think of a pattern for this, merely, several patterns to deal with smaller concerns, such as "differentiate behavious based on the current state or on a parameter".
    I would point out that you probably shouldn't design each form to depend on where it is called from, but merely on what parameter it is called with. For example (assuming your foms are JSPs in a Web application), you can pass a parameter in the URL, but it would be awkward that the parameter be "origin=xyz", instead it should be "detailedOption=true". That seems more evolutive, so that if you ever need the second drop down to be displayed when the form is called from another page "efg", you don't have to modify the form.
    Now if you are worried that page "abc" and "xyz" have to know that they have to call (hyperlink to, or forward to) X which the correct value of "detailedOption", you can still have them call dedicated pages "XafterAbc" and "XafterXyz", and let your URL mapping, or dedicated controller code, map "XafterAbc" to "X?detailedOption=false".
    J.

  • Flex design pattern for BlazeDS transfer objects

    Dear Community,
    I have a question regarding the nature of objects transferd from BlazeDS backend to the Flex client.
    According to some adobe docs all the presentation logic should be in flex and BlazeDS should provide only services.
    The question is what kind of transfer objects should be used? with what level of abstraction?
    To make it more clear let's talk about a simple forum application like adobe forums.
    I have created a Forum service, which returns a Forum transfer object, which has a List of Threads, with each thread having a List of Messages.
    Flex gets the Forum transfer object and does all the presentaiton work.
    This is a very nice seperatin of concerns architecture BUT there are two major performance issues:
    - when the forum becomes bigger the transfer object will be huge
    - the flex will use huge client resources to create the presentation of the forum transfer object.
    So my question is what is your strategy/ design pattern for such a problem.
    An obvious answer would be create services that include the presentation logic and use transfor objects like ThreadListPage which will include only the first 10 threads.
    Thanks in advance

    I think you are going to get a few varied types of answers to a general question like this, but I will comment on a few things.  First, you should only be transmitting the data that you need to use or display to the user at the time.  If this forum was implemented in Flex (I wish) you wouldn't transfer the text for all the threads.  You might not transfer the thread text at all (just the subjects), you'd make calls back to the server to fetch that data when and if you need it.
    Also, I think you are overestimating the resources required for the Flex "presentation layer".  If you think about it, these workstations we have here are pretty idle most of the time when you're at a website.  Nowadays there's plenty of processing power just sitting there waiting, so as long as your design isn't flawed the CPU or memory are rarely going to be a bottleneck with Flex.
    The way I design, BlazeDS (or GraniteDS etc) should mostly just be "serving data".  There is some flexibility available, for example I don't see a problem with putting certain types of business rules (such as a limit on the number of results that can be recieved in a search) within server side code, and validation rules on the Flex side.  So there's not too many "industry standards" in Flex yet beyond maybe what's done in the various standard architectures, at least not that I'm aware of.
    You might find it beneficial to look into some of the various frameworks/architectures available like Cairngorm, Mate, Swiz, and so on.  Learning how they work (looking at examples) would probably answer some of your questions too.

  • How can I develop a web application using EJB design pattern?

    I have searched over the web and found quite a lot of tutorials on how to use the EJB design pattern.
    I know that there will be a home interface, EJB object interface and a SessionBean.
    But the tutorials often only cover a single class, this made me unable to get a complete picture of how EJB design pattern can be implemented into a whole system.
    I am now required to devleop an online shopping web application using EJB and JSP page.
    I think I will need to create a lot of classes: Member, ShoppingCart, Product...etc.
    What I want to ask is that, do I need to create a home interface, EJB object interface and a SessionBean for each of these classes?
    I really need some ideas on how to develop this system using EJB + JSP pages.
    Many thanks to you all.

    For every EJB that you want to create, you will need to code a home and remote interface and a bean class.
    You could start getting your ideas here
    http://www.theserverside.com/books/wiley/masteringEJB/
    http://www.coreservlets.com

  • SERVICE LOCATOR ?? Is it really an interesting Design pattern??

    Hi everybody,
    i've a problem with the J2EE Design Pattern "Services locator" (it's a singleton).
    It is said that by making use of a Service Locator we can :
    - hide to the client the complexities of initial context creation, EJB home object lookup,and EJB objectre-creation.
    - multiple clients can reuse the Service Locator object to reduce code complexity, provide a single point of control, and improve performance by providing a caching facility.
    But i would like to understand at which side should that service locator object reside??!!??
    If it is at server side then the clients need well an initial context in order to make a lookup on that object.
    Conclusion :
    the service locator doesn't hide the complexities of initial context!!
    Furthermore the client has to perform a look-up on that service locator object!! The only advantage left is caching facility.
    If it is at client side, each client needs his own services locator object
    Conclusion :
    multiple client don't reuse the same service locator. What's the advantage to be a singleton ???
    There is certainly something that i don't understand so help me please!! Thanks.

    Hi Yves,
    But i would like to understand at which side should
    that service locator object reside??!!??
    If it is at client side, each client needs his own
    services locator object
    Conclusion :
    multiple client don't reuse the same service locator.
    What's the advantage to be a singleton ???The service locator resides on the client side and is implemented as
    a singleton. Since it is possible that there could be multiple
    class loaders/JVMs on the client side, and therefore, multiple
    instances of the "singleton" service locator. This is typical
    in a distributed environment (e.g. servlets/JSPs in a web-tier
    cluster using service locator). Thus service locator is not
    a truly "distributed singleton" object. But, the empahsis
    is to design the service locator such that it does not hold
    any state that needs to be replicated across multiple
    instances across different JVMs as mentioned. Thus, there
    is no need for multiple clients to use the "same" service locator,
    but still the benefits of implementing this pattern is realized.
    By making it a singleton, and keeping it from holding state
    that needs to be replicated, we realize the benefits of this pattern.
    You may also want to visit the J2EE Pattern interest list
    and see these relevant discussions :
    Topic: Service Locator and passivation
    http://archives.java.sun.com/cgi-bin/wa?A2=ind0106&L=j2eepatterns-interest&F=&S=&P=1026
    Topic: Caching EJBHome interfaces
    http://archives.java.sun.com/cgi-bin/wa?A2=ind0106&L=j2eepatterns-interest&F=&S=&P=9226
    Topic: Using Service Locator for Data Source caching
    http://archives.java.sun.com/cgi-bin/wa?A1=ind0106&L=j2eepatterns-interest#31
    hope this helps,
    thanks,
    -deepak

  • What is the best design pattern for this problem?

    No code to go with the question. I am trying to settle on the best design pattern for the problem before I code. I want to use an Object Oriented approach.
    I have included a basic UML diagram of what I was thinking so far. 
    Stated simply, I have three devices; Module, Wired Modem, and Wireless Modem.
    In the Device Under Test parent class, I have put the attributes that are variable from device to device, but common to all of them.
    In the child classes, I have put the attributes that are not variable to each copy of that device. The attributes are common across device types. I was planning to use controls in the class definition that have the data set to a default value, since it doesn't change for each serial number of that device. For example, a Module will always have a Device Type ID of 1. These values are used to query the database.
    An example query would be [DHR].[GetDeviceActiveVersions] '39288', 1, '4/26/2012 12:18:52 PM'
    The '1' is the device type ID, the 39288 is the serial number, and the return would be "A000" or "S002", for example.
    So, I would be pulling the Serial Number and Device Type ID from the Device Under Test parent and child, and passing them to the Database using a SQL string stored in the control of the Active Versions child class of Database.
    The overall idea is that the same data is used to send multiple queries to the database and receiving back various data that I then evaluate for pass of fail, and for date order.
    What I can't settle on is the approach. Should it be a Strategy pattern, A Chain of Command pattern, a Decorator pattern or something else. 
    Ideas?

    elrathia wrote:
    Hi Ben,
    I haven't much idea of how override works and when you would use it and why. I'm the newest of the new here. 
    Good. At least you will not be smaking with a OPPer dOOPer hammer if I make some gramatical mistake.
    You may want to look at this thread in the BreakPoint where i trie to help Cory get a handle on Dynamic Dispatching with an example of two classes that inherit from a common parent and invoke Over-ride VIs to do the same thing but with wildly varying results.
    The example uses a Class of "Numeric"  and a sibling class "Text" and the both implement an Add method.
    It is dirt simple and Cory did a decent job of explaining it.
    It just be the motivation you are looking for.
    have fun!
    Ben
    Ben Rayner
    I am currently active on.. MainStream Preppers
    Rayner's Ridge is under construction

  • Business delegate and Session facade design patterns

    Does any one tell me, what is the difference between business delegate and session facade design patterns.

    1. Session Facade decouples client code from Entity beans introducing session bean as a middle layer while Business Delegate decouples client code from EJB layer ( Session beans).
    2. SF reduces network overhead while BD reduces maintenance overhead.
    3. In SF any change in Session bean would make client code change.
    While in DB client is totally separate from Session bean because BD layer insulate client from Session beans(EJB layer).
    3. In only SF scenario, Client coder has to know about EJB programming but BD pattern no EJB specialization needed.
    4.SF emphasizes on separation of Verb, Noun scenario while BD emphasizes on separation of client(presentable) and EJB layer.
    Anybody pls suggest more differences ?

  • Design patterns for updating a fact table

    I have a fact table and about 10 dimensions.
    One of these dimensions can be missing values, so the fact table row will link to an UNKNOWN value.
    When the correct value is finally entered in the dimension table i want to update any associated fact rows.
    Whats the most efficient way of doing this?

    I know i have to use a lookup transformation ;-) 
    I wouldnt be at teh stage of even having a fact table if i didnt know that! I was looking for a design pattern, not the name of a shape!
    The solution i went with was to take a hard line on any rows with unknown values. If when importing the data there are unknown values for two of the most important dimensions, those rows are not inserted into the fact table, but instead pushed to an ErrorLog
    table.
    Users run a report that shows what this table contains and if they really want those rows, they insert the correct dimension values and rerun the import, which will only import any rows not already in the fact table.
    This way:
    1. all sorting & filtering issues are resolved as there will be no unknown rows for the most important dimensions used in sorting and filtering.
    2. we can quickly see any rows with unknown values and figure out whats wrong. its always missing reference data that the client didnt think to give us. a quick insert of the dimension data and import and the rows get imported.
    thanks for the replies.

  • Design Patterns/Best Practices etc...

    fellow WLI gurus,
    I am looking for design patterns/best practices especially in EAI / WLI.
    Books ? Links ?
    With patterns/best practices I mean f.i.
    * When to use asynchronous/synchronous application view calls
    * where to do validation (if your connecting 2 EIS, both EIS, only in WLI,
    * what if an EIS is unavailable? How to handle this in your workflow?
    * performance issues
    Anyone want to share his/her thoughts on this ?
    Kris

              Hi.
              I recently bought WROX Press book Professional J2EE EAI, which discusses Enterprise
              Integration. Maybe not on a Design Pattern-level (if there is one), but it gave
              me a good overview and helped me make some desig decisions. I´m not sure if its
              technical enough for those used to such decisions, but it proved useful to me.
              http://www.wrox.com/ACON11.asp?WROXEMPTOKEN=87620ZUwNF3Eaw3YLdhXRpuVzK&ISBN=186100544X
              HTH
              Oskar
              

  • Process Design Patterns in XI

    Hello,
    I heard that XI has got Design patterns such as Aggregation, Serialization etc. in the Process editor. Where do the messages get stored until the aggregation is carried? Does it make use any ODS in Integration server?
    We are using TIBCO and it does not seem to have this functionality.
    Thanks,
    Venu

    Hi Venu,
    The XI Business Process Engine is implemented on top of SAPs workflow engine, so the state of a process (including whatever messages it contains) is stored in the database underlying the SAP Web Application Server.
    Regards,
    Thorsten

Maybe you are looking for

  • Problem in creating a row in backing bean for a view object..

    hi, i've created a view object and am trying to create multiple rows in my backing bean. but am not able to do that one. my 1st row is getting inserted and all the other values am not able to do. can anyone reply to this as soon as possible. Thanks i

  • Program crashes over and over and over HELP!!!

    Hi, Have been trying to record with logic, but it predictably crashes. I have had tons of problems with this program. Can anyone decipher this error report and maybe give me a clue as to what is going on? Backtrace, Format - Frame : Return Address (4

  • How do I connect Airport Extreme in place of Buffalo wireless router in Japan?

    How do I connect Airport Extreme to replace current Buffalo wireless router? ISP is StarCat in Japan.

  • Update set types attributes

    Dear All, i m new to this set types, Please guid me how to update set type attributes through driver program. Through i will get records from ECC, using this i will have to update the corresponding set types of the products matching the Product ID. T

  • How to block remotely my stolen ipad

    Atfer paying my bill, this customer stealth my ipad 2,  it was on May 7th 2012 at Mina, a small food store located at Margarita Island in Pampatar Venezuela. I have the ipads serial number and purchase receipt. I used it as my personal mobil work com