Is it a good design ?

Hello,
I have the following problem:
I have a base class, let's say class Base and 4 children of Base, let's say A, B, C, D. Each of them extends Base. In the Base class I made 4 "fake" - not implemented - methods, let's say k1, k2, k3, k4. Now the design problem/question: A class only uses k1 method, class B uses k1, k2, class C uses k1, k2, k3, class D uses all 4 methods. The reason why all 4 methods are in Base class is that I want to create an array of type Base and then initialize this array with either A objects, or B or C or D ( polymorphism thing :) ). If it's a bad design then how else would you make it ?
If you didn't get what I wrote, ask for more details :)
Regards

Here is how I did it:
I made four Interfaces : A, B extends A, C extends B and D extends C.
A has only k1() method, B has k2(), C has k3() and D has k4().
Implementations of these functions are different in every class.
I have also 4 classes: Aclass implements A, Bclass implements B etc.
Now I want to do the following thing:
Type[ ] arr = new Type[N];
if (....) {
   for( int i = 0; i < N; i++)
      arr[i] = new Aclass();
if (....) {
   for( int i = 0; i < N; i++)
      arr[i] = new Bclass();
if (....) {
   for( int i = 0; i < N; i++)
      arr[i] = new Cclass();
if (....) {
   for( int i = 0; i < N; i++)
      arr[i] = new Dclass();
}Question: what should be the type of "Type", so the program could compile ? If someone has any idea how else this can be solved, feel free to post :)
Regards

Similar Messages

  • How to master good design with EJB and JSP?

    I use JSP to calling EJB. But the .jsp file is complex and it's difficult to maintain...I just want to work higher efficent with EJB,JSP and JavaBean. I want to know is there a good design with EJB and JSP? and is there any good material about MVC for EJB,JSP and JavaBean?

    You should read the J2EE blueprint available on this website. Better download the PDF, and print it for yourself so you can read it anytime.

  • Is this a good design -- XI and another EAI tool in the same landscape

    Hi All,
    I am working in a project wherein the client already has an EAI tool which is based on SOA(Web Services). They are implementing SAP systems in their landscape. They now want to use SAP XI in the landscape for the purpose of integration. They want to integrate their initial EAI tool with XI and have the existing integration with NonSAP systems as it is and integrate SAP systems using XI.
    Is this a good design having two EAI tools being used for integration between two systems? What are the various issues that need to be taken into account?
    Answers will be promptly rewarded.
    Thanks and Regards,
    RM

    R M,
    There are lot of points that has to be considered when evaluating the design of EAI landscape. I heard somewhere that even SAP does not recommend to scrap the existing landscape and bring in SAP XI there. I gues dual hub gateway is very common unless it is a fresh implementation becuase changing the existing landscape is re-investing the cost again for the customers.
    If you ask me then SAP XI is not yet so robust to handle huge volumes in real time data integration and SAP XI can be used in between for integration to SAP system as it is a SAP system and it works excellent integrating with SAP systems.
    Check out this thread which is a transcript of a 10 year EAI architect :
    in my company we had more or less the same situation 2 years back, a existing BizTalk solution, and whether we should introduce XI or not.
    We concluded with the following; BizTalk should be used as the main integration engine between the different system landscapes and ALL external communication, and XI should be used as the integration engine for all data to/from our SAP system landscape. Depending on the integration scenario, we may use both.
    BizTalk will not see any SAP systems, only web services exposed by XI or using IBM MQ depending on an async/sync integration scenario.
    We believe that XI is better with integration from/to SAP, and;
    - In future SAP will deliver out of box integration for the XI system (XI content) for Enterprise Services Architecture
    - Several components in the NetWeaver stack are using XI for communication
    We have a SAP system landscape with several 46C systems (IS/OIL, HR ...) and newer NetWeaver solutions.
    I can give you a brief resume of our experiences – my background is ABAP developer since ’98, I have implemented a few BizTalk solutions to SAP 46C, and I’m a certified XI developer and developed several XI solutions between SAP 46C/640 and BizTalk.
    BizTalk ******
    Overall communication between SAP systems and BizTalk depending on the integration scenario and who is the initiator:
    SAP 46C to BizTalk:
    There are no good mechanisms available for sending data from 46C to BizTalk, we are using HTTP_POST with XML payload. Then you must use the iXML library on the SAP side, its ok, but you will spend, in my point of view, too many hours on XML programming that can be generated automatically.
    BizTalk to SAP 46C - Which SAP adapter to use for BizTalk?
    We started with SAP adapter from IWay, but that adapter gave us a lot of problems on the BizTalk server (pretty complex adapter with strange behaviour, and several integration scenarios stopped working for no reason at all (unstable)).
    Due to several severe problems, we switched to SAP adapter from Microsoft 1 year back in time. If I don’t remember wrong, back then, the SAP adapter from Microsoft did not support parameter of type string or table types – so there are/were some limitations regarding the signature of the RFC function.
    The SAP adapter from Microsoft is more stable than the previous, BUT we have some hick ups with that one as well when BizTalk does very frequent calls to SAP 46C.
    SAP 640 to/from BizTalk:
    I assume you can use the web service functionality on the SAP side in order to send/receive data, but I don’t know whether 640 support asynchronous web service.
    XI *****
    The communication mechanism between different SAP systems and XI are much better than with BizTalk:
    SAP 46C to XI:
    Configure a sender communication channel with RFC adapter; basically the XI system will be RFC server so the only thing you have to do is to create a RFC port on the 46C system “pointing” to the XI system. In the Abap program, you can do normal function calls with destination (RFC port) AND the RFC call will automatically be translated to XML on the XI side.
    Thus, you can forget all about the iXML library and XML rendering of the payload to HTTP.
    Besides, you can choose to use sRFC, tRFC or even qRFC depending on the integration scenario and whether you want guaranteed delivery.
    XI to SAP 46C:
    More or less same as BizTalk using a SAP adapter, but string and table types are supported.
    SAP 640 to/from XI:
    This is a very nice situation, every 640 has a local integration engine, so the main integration engine (XI) can send/receive XML messages both async/sync. Another advantage is using the SPROXY transaction on the 640 system, generating automatically a proxy class being able to send/receive messages based on a message interface defined in XI (outside-in programming).
    Finally *****
    BizTalk and XI are at a conceptual level identical, two integration engines with the purpose of send/receive, route and do message transformation (mapping) using adapters to different technical systems.
    Microsoft has a lot of resources available and for sure, BizTalk will be a very good choice for most companies.
    SAP came late with XI, but they are not trying to make the best integration engine, but good enough. And for sure, I think SAP will come with very nice XI content in time (interface mappings between message interfaces – business solutions) which is beyond BizTalk.
    As an ABAP programmer I just love the transport system between development, quality and production systems. We are using the CMS transport systems between our development XI, quality XI and production XI – it is so nice and fast. With BizTalk you have to create a MSI file (installation file – which files to include…) and somehow transport the file (mail or whatever) to the quality environment for installation – really tedious work compared to XI.
    So we are using BizTalk 2004 and XI 3.0 and are very happy with both.
    Note:

  • Good design choice, different types of customers, from webservice

    Hi, I have thoughts about good design pattern, when doing this:
    You have a webservice where customers coming into your system. The customers are private ones, business ones, and big business types.
    These 3 customer types has different needs, and must have different values like companyname, social security number, etc etc.
    The customer also has some shared types, like customerid, created, updated, etc.
    So what you want to do is to have an interface or an abstract class containing common methods for the customer, then you will create subclasses for the different types.
    I was thinking about creating a factory class and pass in the customer object retreived from the webservice, and in the factory process method create objects on the different subclasses based on what kind of object you get in (private, business, etc).
    So, webservice gets a private customer object, you serialize it and then you pass it into your factory class. And back you get a customer object.
    Now you want to do business logic on the object, storing it to a database, etc.
    So you might still have to create different scenarios based on if its customer type.
    The basic idea is that you want to get the object from webservice, pass it to a factory and get back a customer object which you want to do things with.
    What do you think, what is a good design solution to the problem described?

    To be clear "pattern" has a specific meaning. Your description is a design not a pattern.
    Is the small business one never going to become a big business one?
    Is a big business one never going to become a small business one?
    If the answer to either is yes, then you have one entity with different attributes, not two.
    I have no idea why serialization would matter in this. And your description doesn't explain that either. If you are talking about communication between different boxes then you need a communication layer (and it doesn't appear you are at the level yet where you need to decide the specifics of how that is handled.)
    It is unclear why you would want a factory. But if you just want the experience then you could probably use it.
    Your description isn't nearly complete enough to define how the overall system should behave which is what you seem to be also describing. You need to seperate what the system will do for how it will do it (the design.)

  • Good Design?

    I am not that experienced in Labview so would like to ask the experts.
    I am writing a program, which uses a main state machine and I have multiple sub-Vi's with for each sequence of operation. Within the Sub-Vi's I also use a state machine structure for operation.
    In the main VI, I use shift registers to pass data, each Sub-Vi has it's own cluster, containing Sequences and data. I also have variable clusters as well as well as the IO from the a DP DP coupler which is used in all sub-VIs.
    These clusters are large in size, each containing Sub-Clusters.
    The main VI contains about 15 shift registers
    The program is working well, but I want to have a good design structure as well.
    Any advice would help.

    I am no expert, so wait until the experts comment. Here's my two pennies' worth:
    Your program does sound intensive, having a state machine inside a statemachine may lead to an unresponsive UI. This could be because one of your subVI is trying to do something while the user presses stop button. So if user interaction is critical, you need to look at an event based producer/consumer design pattern.
    You could possibly use FGV's instead of having 15 shift registers to pass data from one iteration to the other, if not bundle all of them in to a type def cluster to make the diagram a bit more readable (I havent looked at your code, so this is just an assumption). Use bundle by name and Unbundle by name to read and write elements in the cluster as this is more or less self documenting.
    Try to use type defined data types (especially the clusters you mentioned) where possible.
    Error handling is important as well, its also a good way to enforce data flow.
    The other thing I would recommend is to go down the certification path as you learn a lot of best practices along the way.
    Beginner? Try LabVIEW Basics
    Sharing bits of code? Try Snippets or LAVA Code Capture Tool
    Have you tried Quick Drop?, Visit QD Community.

  • Fiend class is a good design ?

    Hi All ,
    If we take a pure OOPs concept then private component of a class should not be accessed from outside.
    But this stuff we can bypass using the friend class .
    So my question is is it a good design to have friend class ?
    when to use friend class ?
    Regards,
    Ravi

    Hello,
    from the "pure" object-oriented programming paradigm view, a class should control the access to its members. Members which should be accessable by the outside have to be declared explicitly in the class interface. This information hiding principle has a lot of advantages: Other classes can use a class as a "black box" just by using the methods and fields from the class interface. They do not know and do not have to care about the internal implementation of the functionalities they use. Also, the implementation of a functionality within a class can change without any impact on the users of the class.
    The declaration of friend classes violates the information hiding principle. A friend class can access all members of the related class, so the internal implementation is transparent to it ("white box"). Thus, dependencies between both classes can exist. This may become problematic when the internal implementation of the related class is changed for some reason without taking care of the friend class. Additionally, errors within the class design are harder to find: The error might occur in the related class, but the code which produces the error can be within the friend class.
    So from my point of view, I try to avoid friend relationships between classes whereever I can. However, I have to admit that sometimes it is easier to declare a friend relationship than to avoid it, as this very likely complicates the whole class design. In my opinion, there is no general rule whether to use friend relationships or not -- it depends on the particular case.
    Regards
    David

  • What is a good design for remote Views?

    Hi All,
    I am thinking how would I design my process for performance consideration in retrieving dynamic values of table/view data.
    The requirement is like this:
    1. We have 50 databases residing on each own server counterpart (50 servers).
    2. Each database has table Patch_LeveL (apps_name, patch_level), which contains  just one row only to reflect the latest patch level applied for the apps on this database. Note that are we constantly on applying service packs for this apps.
    3. On our central monitoring server (db). I create 50 database LINKS for each of the 50 databases.
    4. I created 50 views over these links to make  it centralized to represent  the 50 Patch_Level tables. As   patch_level_view1, 2, 3.....patch_level_view50.
    5. I then create a central view as .... as  union of the 50 individual views Actually I am just planning to do the above activity.
    My question is....is this a good design for performance? Can you share be a better approach?
    Is there a limitation of joining "union" of 50 views?
    Thanks a lot,

    Is there a limitation of joining "union" of 50 views?What can happen is if the connection to one of these servers is interrupted, the big "union" view will not work. As said by above poster MV, with lets say an hourly refresh, helps with this situation as you have the data that was gathered last time (and most likely it is still valid).

  • What is a good design application for drawing logos on my MacBook Air?

    What is a good design application for drawing logos on my MacBook Air?  I'm looking for something that isn't too expensive and is fairly easy to use.  I would prefer vector technology.

    You can try Logoist.
    Here is the link to the demo.
    http://www.macupdate.com/app/mac/43694/logoist

  • A good design for a single thread pool manager using java.util.concurrent

    Hi,
    I am developing a client side project which in distinct subparts will execute some tasks in parallel.
    So, just to be logorroic, something like that:
    program\
                \--flow A\
                           \task A1
                           \task A2
                \--flow B\
                            \task B1
                            \task B2
                            \...I would like both flow A and flow B (and all their launched sub tasks) to be executed by the same thread pool, because I want to set a fixed amount of threads that my program can globally run.
    My idea would be something like:
    public class ThreadPoolManager {
        private static ExecutorService executor;
        private static final Object classLock = ThreadPoolManager.class;
         * Returns the single instance of the ExecutorService by means of
         * lazy-initialization
         * @return the single instance of ThreadPoolManager
        public static ExecutorService getExecutorService() {
            synchronized (classLock) {
                if (executor != null) {
                    return executor;
                } else {
                    // TODO: put the dimension of the FixedThreadPool in a property
                    executor = Executors.newFixedThreadPool(50);
                return executor;
         * Private constructor: deny creating a new object
        private ThreadPoolManager() {
    }The tasks I have to execute will be of type Callable, since I expect some results, so you see an ExecutorService interface above.
    The flaws with this design is that I don't prevent the use (for example) of executor.shutdownNow(), which would cause problems.
    The alternative solution I have in mind would be something like having ThreadPoolManager to be a Singleton which implements ExecutorService, implementing all the methods with Delegation to an ExecutorService object created when the ThreadPoolManager object is instantiated for the first time and returned to client:
    public class ThreadPoolManager implements ExecutorService {
        private static ThreadPoolManager pool;
        private static final Object classLock = ThreadPoolManager.class;
        private ExecutorService executor;
         * Returns the single instance of the ThreadPoolManager by means of
         * lazy-initialization
         * @return the single instance of ThreadPoolManager
        public static ExecutorService getThreadPoolManager() {
            synchronized (classLock) {
                if (pool !=null) {
                    return pool;
                } else {
                    // create the real thread pool
                    // TODO: put the dimension of the FixedThreadPool in a property
                    // file
                    pool = new ThreadPoolManager();
                    pool.executor = Executors.newFixedThreadPool(50);
                    // executor = Executors.newCachedThreadPool();
                    return pool;
         * Private constructor: deny creating a new object
        private ThreadPoolManager() {
        /* ======================================== */
        /* implement ExecutorService interface methods via delegation to executor
         * (forbidden method calls, like shutdownNow() , will be "ignored")
          // .....I hope to have expressed all the things, and hope to receive an answer that clarifies my doubts or gives me an hint for an alternative solution or an already made solution.
    ciao
    Alessio

    Two things. Firstly, it's better to use     private static final Object classLock = new Object();because that saves you worrying about whether any other code synchronises on it. Secondly, if you do decide to go for the delegation route then java.lang.reflect.Proxy may be a good way forward.

  • 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.

  • Is this a good design pattern?

    Hi,
    I am working with a team to create an application that can acquire data from up to 24 thermcouple channels.  We plan to create a wizard to assist the user in setting up the test (specifiying stop conditions, sample rate, channels to sample, output file, and email/text notifications).  After the setup, if the user does not cancel out, then the program continues.  We have defined parallel loops and their roles, trying to fit into a producer/consumer design pattern.  I have attached the main file which shows the structure of the program.  We are trying to keep it clean and modular.  Before diving into development, we are finalizing a detailed design specification so that different people can work on each of the loops' subvis.  I was hoping that people could review the block diagram and offer suggestions for improvement or validate that we have chosen a good method of implementation.
    Notes about the block diagram
    The plan is for data driven stop conditions to be detected by Event Notifier, handled by the Main UI event, and then the Data Collector is instructed to stop (as well as the Main UI loop).  When Data Collector stops, it releases queues, the queue reference becomes invalid, and then the loops with the Dequeue will be stopped.
    I am not sure if an additonal event structure should be in the DataCollector to specifically handle the Stop button on the UI because if it is in the Main UI event structure, the DataCollector would not be stopped immediately.  This is important to stop quickly because the sample rate could be VERY long.  I understand about using an event structure instead of WAIT, but didn't know if there is an efficient way leaving it down in the Main UI event structure....????
    Data Collector is the producer, it currently only collects data and passes it on.  If the program is going to contain a start collection button, or pause/resume, I need to figure out how to handle this with the Main UI event structure.
    Event Notifier consumes data from the Data Collector.  It looks at all data and should set a flag if a stop condition is met.  The flag will be handled by the Main UI event structure to tell Data Collector to stop.  The event notifier also sends a notification to the Email/Text Caller when thresholds have been exceeded warranting a reason for the user to be notified via text or email.
    Email/Text Caller waits for notification and then calls a subVI to send an email or text with certain data and channel information.  The subVI call is lengthy, so we decided to put this in its own loop instead of a case structure inside the Event Notifier.
    Report Generator logs all collected data to a file.  A second queue was used, but uses the same data as the first.  Is this the correct implementation since two consumers need the same data?
    Main UI - handles changing of sample rate, possibly the stop button, possibly start/pause/resume of data collection.  Also handles when Event Notifier sets flag for a data driven stop condition, which then should provide a mechanism to stop the Data Collector.
    A big question that i have is.... Should the Main UI event structure just be in the Data Collector so that the loop can be stopped immediately?  All of the UI events (stop button, start/pause/resume data collection) directly effect the Data Collector.  Should the data Collector have a state machine instead?
    I feel that the 3 consumer loops (Event notifier, Email/Text Caller, and Report Generator) seem like a good implementation, but i am not confident about the Data Collector and Main UI loops.  Should they be combined?
    Solved!
    Go to Solution.
    Attachments:
    updatedMain.vi ‏13 KB

    A couple of thoughts:
    Overall it looks workable- remember to name your queus and notifiers- then you can depop the BD and launch each loop in its own sub-vi without wiring all those queues between loops- Just obtain ref to named queue.
    "Data collector" needs a supervisor to control how often the data is collected- I'm thinking a QSM with "init- collect- stop" states.  A simple timed loop could produce the "time to acq ticks" under control of the sample rate control. This puts both the DAQ init and cleanup functions within the Data Collector's perview so it aids coehesion and solves the exit without waiting for the loop to iterate.
    I'm not a fan of duplicating data- I assume analisys is pretty much just some comparisons- so it is pretty quick- Why not append summary data to the same queue? And make it a single element queue- the report loop can then inspect the queue and look for a summary data "index" - if its greater than the last index written append the darn data to the report?  Preview queue works great for these situations.
    Do not combine the UI handeler with anything else! Do you see the snag?- hint: here thar be spaghetti.  keep the functions seperated for solid scalable and maintainable code.
    One last thought:  Its getting less popular to stop loops on the error out of a dequeue.  First it returns a default element that can cause your listeners some headaches.  Second it doesn't let you run cleanup code.  Use a stop command <enum> built into the element data as an executive to determine when to stop.  We'll try to get the examples updated to show current best practices.
    Jeff

  • Force vert scroll bar & good design reference

    OK, yes I'm a self-taught nube with LiveCycle. After numerous tutorials and lots of reading, I know I need to code to force vertical scroll bars to appear as default on a multi-line text field. I'm a designer - not a coder- and I have yet to find an example to plagiarize work off of. Can somebody please show me how?
    Also, I started by scanning a form and letting LC design a form from that. As I explore the hierarchy, I cannot decipher the magical, mystical logic as to how text and text fields are distributed amongst cells, paragraphs, and rows; why some tables get a header row and others have the header shoved into a body row; and so on. To further my education, can somebody also point me to a good treatise (preferable on-line) for basic best-practices for design within LiveCycle?
    Thanks in advance!
    If you give a man a fish, he won't be hungry for a day: if you teach him to fish, he won't pester you in this forum again!

    OK, yes I'm a self-taught nube with LiveCycle. After numerous tutorials and lots of reading, I know I need to code to force vertical scroll bars to appear as default on a multi-line text field. I'm a designer - not a coder- and I have yet to find an example to plagiarize work off of. Can somebody please show me how?
    Also, I started by scanning a form and letting LC design a form from that. As I explore the hierarchy, I cannot decipher the magical, mystical logic as to how text and text fields are distributed amongst cells, paragraphs, and rows; why some tables get a header row and others have the header shoved into a body row; and so on. To further my education, can somebody also point me to a good treatise (preferable on-line) for basic best-practices for design within LiveCycle?
    Thanks in advance!
    If you give a man a fish, he won't be hungry for a day: if you teach him to fish, he won't pester you in this forum again!

  • Good design for property files?

    Hi
    Id like to put the property file for my application in the users home folde, and on any *nix OS (Linux, Unix, OS X,..) thats a good solution if i simply make a .xxx directory (a directory starting with a '.'), and then the user cant see the directory by default, and then place all my configuration there under. But is this a good cross platform design, or is there a better way?
    /Thanks

    I think it's pretty decent/standard. I believe System.getProperty("user.home") will give you C:\Documents and Settings\username by default on Windows XP--on my machine there are a couple of .folder configuration directories in there for other java programs (rssowl and jprofiler)

  • Is this a good design?

    I am designing an online application. There is a super class DataItem and 3 subclasses. Also, each of the classes has a dao class with the same inheritance relationship. In each sub DAO class (extends DataItemDAO), it has its own getContentItems() method which calls getItems() method in DataItemDAO class.
    The getItems() method in DataItemDAO takes DataItem as one of its parameters. So it could get all the setter methods of the object and invoke them using Java API and store the objects in a Vector and return the Vector. Basically, my idea is to have get, create, update, and delete actions all handled in the superclass level. Since each subclass has its own attributes besides the ones in the superclass, I guess I have to use Java API to get the setter methods in order to set attributes of each subclass object.
    Do you think this is a good approach? Are there any cons using Java API to invoke methods? Any suggestions/alternatives? Thanks.

    I guess when you write java api you really mean Java Reflection!?
    If so here are my thoughts (well I guess they are there even if you refere to something completely different)
    a) Reflection is slow and hard to debug since you have to do a lot of the stuff at runtime which normally the compiler gives you at compile time.
    b) It sounds quite flexible
    So the question is: what is more important: speed (development and execution wise) or flexibility.
    You might also consider an aproach which generates your dao classes. It's flexible and fast (once you created the classes and their instances)
    One serious drawback in simple using the getters and setters is that you can't simply add accessible fields which aren't persistent.
    Regards
    Spieler

  • Is there a good design software for Macbook?

    Hey guys, I recently got a 17 in. Macbook Pro so I can start designing phones, computers, tablets, and laptops. I just cannot find a good, professional one that would work good. Can you guys give me some recommendations or tips and ideas? Thanks a lot.

    Look for them at macupdate.com. There are plenty of them but they are expensive.

  • Does this sound like a good design for simple db lookup?

    I want to separate the gui form the behind the scenes stuff so 2 classes. One for the gui (gui.java) and one for the database stuff (dbQuery.java). I know the syntex is not accurate but it's sort of pseudo-code - Here's how it looks:
    public class gui extends JFrame {
       string name, address, city, state, id
       public static void main {
          create gui         //all the swing stuff goes here
          actionlistener{          //waiting for button to be clicked
             when button is clicked,
             dbQuery dbq = new dbQuery(id)
             name.setText(dbq.getName())
             address.setText(dbq.getAddress())
             .....        //get the rest of the information needed
    class dbQuery{
       dbQuery(string id){
          //do all the stuff to get connection. create statment, get sesult set...
          rs.next();
          string name = rs.egtString("Name");
          //.... assuming all db fields are appropriately named
    }This is my first attempt at designing more than "Hello World" and your input truly is appreciated!
    Merry Christmas!

    I am partial to the database layer and the gui layer using a primitive and collections of primitives to share data.
    A primitive is implemented as a class in java but it is not an object. Rather it just serves as a convient way to group the certain attributes together. Like this
         class CustomerPrimitive
              public String name;
              public String account;
              public Boolean preferedCustomer;
              public Double accountBalance;
    .When I use primitives I tend to use objects rather than java primitivers (Integer rather than int.) This allows me to use the primitives for queries also - a null means don't query on that. In addition it allows me to return null values as nulls.
    It is important that a primitive not have any substantial behaviour. For example there could be a validation method that verifies that the account number is not null. But there must not be a validation method to verify that the account number is unique. The first is implemented using simple java (perhaps with java.lang), while the second requires the interaction of numerous classes.

Maybe you are looking for