Bad OOP design?

I have to access some data before my program starts (to prevent a slow down while the program is running). The thing is, I need to init some objects before my program loads. It works fine now, but when I do the thing that I need the objects for, it hangs for a very short time (while it creates them, you see, right now I can only create them when the action they are needed for is called; it is to detailed to explain). The problem is it just looks unprofessional. Anyway, java.awt.component has a method that would make it possible for me to do the object creation before the program starts. Would it be bad to make a class that extends Component, and then define a method in there that get the information I need to makes it possible for me to create my object before the program starts? Is this bad OOP design?
Thank you!
Joshua

Of course you can't really initialize stuff "before your program loads" since the initialization is part of your program, just before you program tells the user it's loaded.
Probably the way to intialise stuff early is to do it in static, which will happen as soon as the class loads.
Mostly you can do it with static object variables initialised to new objects.
But you can get fancy and put a static code block in the class. Just a piece of code under
static {
  .. do some initialization

Similar Messages

  • Book Review: A Serious Guide to OOP Design Patterns

    I've just finished reviewing a new book: AdvancED ActionSpript 3.0: Design Patterns by Ben Smith, published by Apress as part of the Adobe Learning Library
    I liked the book very much and I wanted to share my discovery with those of you who (like me) would like to bring the advantages of Object-Oriented Programming and Design Patterns to your Flash/AS3 application development efforts.
    I posted my review (“A Serious Guide to OOP Design Patterns”) on Amazon just the other day. Take a look at my review and browse through Mr. Smith's book—if you're interested.

    Nikimathew wrote:
    Every now and then I ask people if they are familiar with the book, Design Patterns: Elements of Reusable Object-Oriented Software. On such occassions, I'm often surprised to hear someone respond, "Yes, I've read it." Having spent close to three years running a study group devoted to understanding the subtleties, combinations and variations of the patterns in this book and others, I am often compelled to ask these individuals if they actually believe that the book can be "read" rather than "studied"? trolling for new members?
    three years? c'mon. i love the GoF book, but it's not holy writ. and it hasn't saved object-oriented software development.
    sounds like you need to move on to a new topic. go buy another book.
    %

  • MEGA 180: A story of stupidity mixed up with bad product design

    This is more for a word of caution to Mega180 users and future owners.
    A bit angry as I managed to burn ( physically ) 2 harddrives  because of carefulness about 10 mins.
    Spend quite some time looking for a SATA to ATI power converter while looking for a solution to CPU temp problem. Could not find one ( and  I don't know if any one does it )
    As my old HD did not start the OS on Mega180 for some data transfer I was not able to use my USB external HD. So I decided to connect old HD as slave and do a HD to HD transfer. Here comes the bad design, the HD connection cable specifies a slot for a slave HD however there is only one power connector (ATI) for supported IDE HD. and there is a useless SATA power connector,it is useless as MEGA 180 does not support SATA.
    Here comes the stupidity, for a min I came up with the bright idea of using the CD drives power connector ( I now remember that I ruled this option earlier, I wish I remembered it all along) As there is always a current on this cable (when there is a power connection - for the HIFI mode to work ) I guess some static electricity effected my HD. Not having realised the HD is already affected, I swapped the cables as the HD connection cable is not long enough to keep 2 HDs in a steady state.
    As a result both my HDs are now not working, when I tried the original master HD I was horrified to see a spark and some fume  
    I wish I never tried to use my old graphics card - which I wanted only for the DVI support. This led to CPU temperatures of average 70 degree celcius and when I ever I tried to use the PC properly I was had to turn it off due to extreme temperatures over 75 degree celcius.
    All I was after is a troublefree smooth working nice looking PC, yet I am stuck now... I am both upset for the data I lost as well as hours I spend in trying to put this thing together. I will decide in the morning to return or keep the product. If I keep it the next challenge will be getting my external HD to run an OS as I need to save up again to buy a new HD, I was hoping my next HD would be a SATA one :(
    This is definately a bitter lesson. Such a pity that with just a little more effort MSI could have really improved the profuct most are listed here but I want to summarise:
    1. before getting the new product out try fitting a new graphics card and a TV card and operate both for 2 hours... That is if you could fit them both in the first reason why you could not is the cables from power supply is unnecessarily long for supplying power to the board and unsuitably located. the best you could do is place them all infront of the cpu fan.
    2. It is really great to have detachable ODD and HD yet Floppy drive ( card reader ) bay is static
    3. a better location for CPU or card slots would have contributed to airflow far more.
    Better close here... I am still not sure if positives of the product companates all the negatives.  

    Simply, be aware that the power cable for the CDRom is live most all the time that your backpanel power cord is plugged in. Its for the support of CD/MP3 in HI-Fi mode. If you shut down your system, and not unplug the power, and you try to connect or disconnect anything to the IDE cable, and you are using the power cable for the CD, you can cause static/surging on the component you are hooking up....
    If you must hookup an alternate drive [slave] for data dumping/imaging etc. use a Y cable from the HDD power cable. It only activates when the PC power switch is utilized....

  • OOP Design: controllin​g multiple (similar) devices

    Hi guys,
    We have some software that controls different kinds of "widgets." They are identicle  in function, but they are from differering vendors and have different drivers and APIs. But here's the tricky part: they may be used by themselves, or in any combination you can  think of, up to 3 at a time. 
    Currently, we use a seperate version of our software for each widget combination, duplicating a massive amount of code-  since the only thing we do with each widget is configure it, then read its data (which it continuously takes), then close it when the program is closed. The rest of the software is the same. 
    I'm wondering what the best approach would be to combine the code. I'm thinking LabVIEW Classes would be a good approach, but, I am new to OOP so I'd like some advice with the design. I've seen the example "Board Testing", that looks interesting and somewhat similar - there they use a different subclass for each board. Analogously I guess I would use a different subclass for each widget. But I'm not sure this is a good idea, since I can have various combinations of the widgets. My main class wire would then have to contain multiple sub-classes. 
    Any ideas?

    pobrepablo1 wrote:
    OK, with these comments in mind I've created an Initialize method. "Wrapper" is the name of the driver refnum.
    I'm calling this subvi with "initialize" as the argument iff First Call? is true. I think this is the best approach? Or at least simplest for me. I've never used DVRs before (except on a TV... )
    This would not be the way that I would implement this. First of all I would have explicit methods for my operations instead of implementing like the old style action engine. Also, I would store the data in the class private data, not in unitialized shift registers. I would consider using a better name than "Wrapper". It is a poor name for your data.
    Mark Yedinak
    "Does anyone know where the love of God goes when the waves turn the minutes to hours?"
    Wreck of the Edmund Fitzgerald - Gordon Lightfoot

  • Bad MBA design

    I've had my MBA for a while now but had never taken it with me to travel. I had the opportunity to take it this weekend and discovered a major design flaw!
    It look like the trackpad button touches the area of the screen right below the isight and, when the MBA is moved around with the lid closed, the two are in contact and rub against each other creating dark scratches on the edge of the screen!!!
    This is really bad. I guess it doesn't show until you lug it around without the foamy paper thing that comes when the MBA ships! I guess I will start using it to prevent such problem.
    Anybody noticed the same thing?

    Looks like I'm not the only one then.
    If you are going to transport it around without the foam thingy between the screen and the keyboard, I suggest that you try to put the least amount of pressure towards the central edge part of the MBA (right above and below the trackpad when the lid is closed) to avoid this problem!
    I had my MBA in my messenger bag and the fact that the top part was being compressed created this problem. Also, the fact that I was picking up the MBA by holding on the central edge of the MBA to take it out of my messenger bag probably aggravated the issue!
    Be careful guys, this is obviously a design flaw. The rubber part around the screen should have been thicker or the trackpad should sit a little lower....
    Cheers...

  • N97 BAD Software Design

    This phone, the WORST Nokia phone I've ever had, and very probably the last, never ceass to amaze me with just how BADLY the software is designed. 
    The latest disaster: I am trying to set up the WiFi to connect to my wireless router.  OK, great it sees the network and asks for a Passkey (as it is encrpted); gives me an input box to enter the passkey.  Oh Dear, my passkey is 64 digits long and consists of random lower case, uppercase letters and numbers.  It is a strong encryption key. 
    But do, Nokia SERIOUSLY expect me to type this in digit by digit??  I have looked in vain for ways to enter this passkey efficiently - the obvious way - pasting it from off the clipboard (oh yes, I've successfully got the key pasted ONTO the clipboard from a text editor); appears to be too clever for Nokia.
    Unless I have overlooked something, there appears to be no way to cut & paste into the Passkey dialog, and apparently no way to do it from the keyboard either.
    SO I guess WiFi is another feature I won't be using on this **bleep** phone!
    NigelS

    Ok, I'll try and save you a bit of time with a medium as apposed to a short cut. Put your passcode in notes in the Office app, then WITHOUT using QWERTY open the note youve done, run your finger over the text, select copy. Go to search for wifi, when asked for passkey don't use QWERTY just tap it and when virtual keypad come up tap the box next to tick with 3 horizontal line in it, select paste, and there you go, takes abot 7 seconds once you have passket saved.
    Good Luck
    If I have helped at all, a click on the White Star is always appreciated :
    you can also help others by marking 'accept as solution' 

  • Bad Software Design

    As prompted by the support tech who completely agreed with me, I post my anger here to warn others of the potential one click destruction..
    Im a new Ipod user, a classic.. A nice device. Itunes is alright over all except where warning of bad user decisions is concerned..
    I wanted to reorganize my library having just gotten it all nice and neat on the ipod. So I deleted all my old music folders, cleared my playlists in Itunes and clicked sync.. No warning, nothing, and in a few seconds 20 years, gone with the closest back up in a computer so old its doubtful the drives still work, provided i can find it.
    You would think in logical software design, where the syncing of drives is concerned.. In the event a sync would erase all data on a device, a warning would be appropriate. Now if there was a warning, with one of those don't bother me again with this checkbox, that box shouldn't be there.
    ITunes, you suckzors and I'll be rid of you as soon as i find an alternative that I like.

    Ok, I'll try and save you a bit of time with a medium as apposed to a short cut. Put your passcode in notes in the Office app, then WITHOUT using QWERTY open the note youve done, run your finger over the text, select copy. Go to search for wifi, when asked for passkey don't use QWERTY just tap it and when virtual keypad come up tap the box next to tick with 3 horizontal line in it, select paste, and there you go, takes abot 7 seconds once you have passket saved.
    Good Luck
    If I have helped at all, a click on the White Star is always appreciated :
    you can also help others by marking 'accept as solution' 

  • Non-numeric primary is good or bad for design

    In general, the primary key created using the non-numeric key is good or bad ?  Any specific reason?

    Numeric datatype is good for primary key because :
    1.No need to implicit conversion
    2.NO overhead in using a NUMBER datatype in joins!!
    3.Auto primary key index will be used since there is no conversion require for numeric datatype.
    All I learn and came to know from Sybrand's reply at below link:
    optimum datatype for primary key column O9i - Oracle Database
    Regards
    Girish Sharma

  • Bad SmartScript Designer popup behavior

    All,
    I'm hoping someone will recognize a simple but EXTREMELY annoying problem I'm having when designing SmartScripts:
    When I drag a question, page, or branch from the palette to the design pane, the select applet appears BEHIND my main application window,
    so I have to minimize the application, pick the question (or page or whatever), click OK, restore the application, drag the next question,
    minimize the application, pick the question... and so forth, ad nauseum.
    This is for a customer-facing class, so I'd like to:
    (a) Resolve it, and
    (b) Show customers how to resolve it if they encounter it.
    Anyone ever seen anything like this? It happens on my machine with IE6 SP 2, but not with IE6 SP1, so I'm fairly sure it's related to IE6 security
    settings, though I didn't find a difference between the settings on the two machines.
    Joe

    I just sent a feedback to Apple, hoping they will find and solved the problem here...

  • OOP Design Theory

    Hi,
    When designing a GUI Application, what is the best way to structure the objects.
    Would It be best to have a functional class (the class that does all the processing work) and then have another class that is linked via composition, that handles all the GUI functionaility for that functionility (which is normally encapsulated within a window or dialog.
    If so is it best for the functionility class to create and hold an instance of the GUI class or the other way round.
    Many Thanks
    Cheers
    Alex

    If I was to do it from scratch what implimentation
    key points would you suggest.The key point is to use existing frameworks and focus on designing/building/coding the Model. The Model represents the core functionality of the application (what is does/the verbs of the application) which is based on domain/business requirements.
    Before starting on anything related to implementation. The first step is to gather/derive/discover the domain/business requirements. Once you have the requirements, you can then start on creating a technical design, once you have a technical design, you can start on create a prototype of the application which implements a few of the highest.most important domain/business requirements.
    Once you have an executable prototype, you can revisit the technical design and if everything is ok, you can work on the second phase of the prototype and implement a few more domain/business requirments.
    Once you have the second iteration of an executable prototype, you can revisit the technical design and if everything is ok, you can work on the third phase of the prototype and implement a few more domain/business requirements.
    When everything is implemented in the prototype, you can put the application into test mode and then when done with that put it in QA cycle....and then poof, you have a working software application. Sounds easy....good luck!
    Check out the Spring Framework

  • Tower Defense Game - OOP Design

    I'm making a tower defense game in Flash CS5 using ActionScript 3. Each object will have its own class. There is a class for towers, a class for creeps (enemies), and a class for the projectile coming from the towers. There can be multiple instances of towers, projectiles, and creeps at any time. How could I use the hitTestObject function to detect a collision between a projectile and a creep?

    I would probably create a timer that checks all the projectiles that you have on the stage and see if they are "hitting" any of the other items on the stage. This would require you to probably creating arrays for the items on the stage. I would have an enemy, tower and projectile array that stored the movie clip when it was added to the stage. So when the timer hits the handler it would cycle through the projectile array and see if it's "hitting" any of the objects in the other two arrays? Or you could probably just do a projectile array and a collision array. The collision array could contain all objects that a projectile could collide with?
    Just a thought...

  • Is this a bad J2EE design?

    Hi, I've implemented a bulletin board system with JSPs and Stateless session beans. The JSP assigns 1 Stateless Session EJB to each client's HttpSession. And if the session times out, a new session is created and a new reference to a Stateless Session EJB is obtained.
    I've seen an example that uses 1 Session EJB per JSP page (rather than 1 per client's session). But it seems to me if you do it with 1 Session EJB per JSP, then you'd have to synchronize access to this shared Session EJB, since the JSP is executed by multiple threads at the same time. Since the majority of the work is done in my Session EJB (accessing the entity beans), it seems like having to synchronize access to it would defeat the whole purpose of having multithreaded JSP execution in the first place.
    Any thoughts?

    Yes could you please explain how its different for
    Session Facade Session Beans (SFSB)? SFSB means StateFul Session Bean. You cannot call stateful session beans conccurently. It will cause container to throw an exception.
    If you use stateless beans (doesnt matter if it's a facade or not) than you dont have to worry about this.
    Because thats
    actually my setup. I have 1 Session Bean per Client
    and each session bean calls methods on the entity
    beans that map to the database tables.

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

  • Components inside components - Bad design?

    Is it bad practice/design to nest components inside components using Flex 4? Should I simply be creating components and inserting them into my main application as below, or doesn't it matter?
    <com:MyComp1>
        <com:MyComp2>        <com:MyComp3>
                <s:Label text="This is a test."/>        </com:MyComp3>
        </com:MyComp2></com:MyComp1>

    It all depends. Knowing nothing about the components, all I can say is that it depends on the complexity of the components individually and collectively as well as what level of reuse you may desire.

  • Large App Design Class Structure - OOP or MVC?

    Helloooo Everyone!!
    I used flash a few years ago and am now getting into as3, I began watching hours of as3 tutorials and training in preparation to build a web app with multi user access and the structure of the design is a bit beyond my skills and need help please.
    My problem: I can design well in flash, love the graphic design tools and can draw the screens the way i want my app to look; i can build different library components and fla's and set up the project files.
    I best give a brief explanation of the system i want to design.....
    I am building an app, where different business types all work together on properties, repair projects and associated property data.
    For example a property owner owns a property, an agent runs the property for the owner and finds a tenant to live in the flat, the tenant who lives in the flat will use the online facility to tell the agent about repairs needed, or pay rent online, or check diary events such as when he needs to renew his tenancy or insurance. The repair the tenant requests will be authorised by the agent and a tradesman will then have to interact with the repair details and provide a quote or just carry out emergency work.
    First dilemma... Do i use MVC Architecture Or Object Oriented programming with custom classes.
         I was planning on the latter - OOP
         I cant quite get my head around how to think about structuring the folders and classes???
    For example. Do i build a class for 'Property' a class for 'projects' a class for 'project tasks' etc
    Is it that you think about Admin for example and build a class for invoices, a class for quotes.
    Different users will access the same property but see different information relavent to them only
    Could someone please mentor me through the design process? You can see the flash design at www.milesquicker.com/projectplanning
    I would be eernally grateful
    Miles

    MVC is an OOP Design Pattern.
    For a program like this i wouldn't use the MVC design pattern.
    I will probably create a class for each section in my application.
    Design Patterns are an advanced topic of OOP and i dought that you will be able to master it after watching
    a few tutorials, same goes for OOP. If you are just starting with programing i would suggest you to start with procedural programming
    and when you feel comfortable with that you can get into OOP although for an application like yours OOP will be the best solution.
    I dont know anything about your programming skills but the pull of an application like that they got to be really good.
    I would also suggest that you will look into flash and mysql because you will have to create databases that will hold the information.

Maybe you are looking for