Interfaces for your own classes - do you bother?

Hi All,
before anyone gets upset, I did post a shorter version this to the Java Prog forum a couple of days ago. I'm reposting here because the thread was pushed down the list just as comments were getting interesting, and I was tossing up which forum was most appropriate anyway...
OK, I'd like to pose a general question on the use of interfaces with your own classes. I am totally behind the concept of using appropriate interfaces for declaration of vars, parameters etc (i.e. use "List" rather than "Vector"), but what about your own classes?
If I have a class in my application that doesn't fit into any kind of framework or class hierarchy, subclass of object basically, should I write an interface with all the same method sigs and use that rather than the class for my vars, params etc? This would make things more flexible in future, enabling you to swap classes in and out of your app more easily.
Taking it a step further, how's this for a design methodology: For every class you write (once again classes that don't fit into your own or somebody else�s hierarchy or framework) do the following
1. Create an interface (MyInterface) that maps 1 to 1 to that class (MyClass), with all the same method sigs.
2. Make the constructor private and manage all the creation of instances of MyClass through a factory that returns objects of type MyInterface.
If you do this there will be no mention of any of your concrete classes anywhere in your app except the factories, making it easier to refactor etc. Do this for all your classes.
A little sketchy but I hope you get idea. Is this complete overkill? Is there a down side to this? Does anyone do anything like this?
Cheers
Matt

Although the pattern you describes adds flexibility, it also adds complexety.
Imagine somebody is looking at your code and from what he sees he deducts that the next thing to look at is the concrete class which is used at a given place.
If you used an interface, he must find out which implementing class is actually used at this place. It's not a big thing, but if every single class has its seperate interface and factory I would consider it overkill ... after all you have to write all the boring code for this.
In the case of doubt I'd agree it's better to throw in an interface and a factory instead of refactoring thousand lines of codes afterwards. But if nothing hints toward a second implementation of the interface, or another reason for using an interface don't bother to write one.
As a general rule I use something like: Don't use a general rule. ;-)
Spieler

Similar Messages

  • [Request] Betty: Friendly English-like interface for your command line

    Anyone with the capacities and interest to maintain Betty?
    Betty is a friendly English-like interface for your command line.
    She translates English-like phrases into commands in case you every run into situations like this.
    This means you don't have to leave your command line to look up an obscure but useful command. Just ask Betty!
    Discussion on reddit: http://www.reddit.com/r/linux/comments/ … x_command/
    Source on Github: https://github.com/pickhardt/betty

    I liked a lot of the ideas you posted.  Though I have to disagree with the idea of having tablets being into the size range of over 12".  You start getting larger than that and you may as well start using a laptop. On the flip side of that, I have to agree that there are too many of the 7" available,  which are almost too small.  The 8-10" tablets give you the portability and smaller size people want for stuffing into their bags,  purses, etc. The larger tablets are getting into that bulky area and that defeats the purpose of the tablet to begin with. Unfortunately I find myself using e-books more than I intended,  but I don't need a full, or larger than a full, sized sheet of paper.   They get harder to handle,  even with Lenovo 's great form design.  
    The only reason to have more than one tablet is if the developers can't come to terms and allow their products to be used across the board (talking of Amazon and Google here). I personally don't want to be carrying around more than one tablet and a phone. I want to simplify and streamline not add more bulk. 
    I loved that you pointed out that our voices will never replace our fingers. I don't like speaking to inanimate objects; too many experiences with automated phone services that did not end up well. 
    I congratulate Lenovo for their innovative design with the Yoga tablets. 

  • Sync message, "You have changed the settings for your iphone.  Would you like to apply these changes?" What does this mean?  I don't recall changing anything...

    Sync message, "You have changed the settings for your iphone.  Would you like to apply these changes?" What does this mean?  I don't recall changing anything...

    The main settings that are changed in these cases can be found in this article:
    http://support.apple.com/kb/ht1386
    To ensure you don't lose any data you don't want taken off, ensure that each Summary, Apps, Music, Movies, TV Shows, Podcasts, iTunes U, Books, & Photos have the settings you would prefer on the computer. 
    If anything gets changed on any of those pages, you will be prompted with that message.  If they look fine, especially after adding some media like songs or videos, then you can apply the changes without fear.

  • I need chords that are unavailable once you make a "key selection.  What would be ideal is for APPLE to allow you to use the 8 available chords for your own choice.  It is very limiting.  Especially when writing.

    I want the ability to load chords into the 8 available positions once I have chosen a KEY.  Currently Apple loads up the primary major and minor chords within that key.  However it would work much better if I had the option to replace some of their choices for my own.  In some songs I could use a 7th or not use a minor. 

    Yes, this would be VERY helpful. right now, the chord selections are limiting -- the ability to choose which chords you want in your 8 chord lineup would be very, very beneficial.
    I understand that the automated choices help the musical novices to find chords that are in the same traditional family. However, maybe the ability to override that or vary the selection would be good for both novices and more expert users.

  • HT202696 What happens if Apple Support expires for a product?  Does it mean there is no more help available and you are on your own just because you have an older Apple product?

    We have a family of Apple products at home, and with every new one, we learn a new aspect of the Apple Life.  After switching to iPhone 5S and struggling between some applications, I've decided it is time to upgrade rest of my older devices requesting an IOS Upgrade to 8.1.2 for weeks.
    My older iPhone 4 didn't have an upgrade, which was not advanced enough anymore to carry a new software, this I understand.  The upgraded iPod Touch and iPad Mini don't seem to have any problems with the recent changes so far.  However, the older iPad (2) we had is messed up, just like many other people's as mentioned on the pages of these discussion groups.  According to these user comments / complaints, it is obvious that upgrading to IOS 8.1.2 was not the right option to older version iPads just like it was not for iPhone 4; actually it shouldn't be an option in the first place.
    On my previous problems with iPhone 5S, I've come to realise the practicality & functionality of the Apple Support system when contacted directly, instead of going through many discussion pages of people with same or similar problems where everybody is asking but just a few is replying.  So, I wanted to give it a try to find a solution to my recent problems with iPad, but this time Apple Support pages replied with "Technical Support & Service Coverage are both Expired" message.
    First, I did not know that Apple supported its users personally, and I loved it.  Maybe this is because I didn't have previous problems with my old iPhone and iPad.  Especially the Apple Support - Chat option I preferred, where I got help step-by-step from Apple operators.  And then, I did not know that this service support was only for my devices until an expiration date, and this did not please me much.
    Can anyone enlighten me on how to receive any response from Apple about what to do with problems of an old Apple device?

    And as far as paying for phone support, here are a few tips:
    If you call your carrier first and then they route you to Apple, you usually don't have to pay for phone support.
    If you are talking to Apple and they ask you to pay a support fee, ask if you can get an exception this time.  That usually works once, but they keep track of the times you've been granted such an exception.
    If you still end up paying the support fee, that fee only applies if it's not a hardware related issue.  In other words, if it can be fixed by just talking over the phone and following Apple's instructions, then the fee applies.  But if your device is deemed to have a hardware failure that caused the issue, then the fee should not apply, and you can ask for it to be waived after the fact.
    This forum is free, and almost all of the technical support articles the Apple tech advisors use are available on this website.  Literally 99% of what they can do over the phone is just walking you through the publicly available support articles.  In other words, you're paying the fee to have them do your research for you.  It's like hiring a research consultant to go look stuff up in the public library so you don't have to.  You're capable of doing it; you'd just rather pay someone to do it for you.
    It's like Starbucks.  You know how to make coffee.  Everyone knows how to make coffee.  And Starbucks coffee isn't any better than what you could make at home for far less.  But you want the convenience.  So you're really paying a convenience fee.  Milk is more expensive at 7-Eleven than it is at the grocery store... because it's a convenience store.

  • How to get context information in your own class

    Hi,
    I'm new to Java and I'm trying to create my own class which stores some constants like for example mailServerHost. The class would look something like this:
    public class AppSettings {
    private static String mailServerHost="localhost";
    static{
    if(###online-server###)
    mailServerHost="another mail server";
    My problem is the if(###online-server###). I don't know how could I find informations about the underlying server.
    Is there any way to find out informations about the context(server)?
    Thanks,
    IMIA

    Do you still need ?n this case 2 different
    property-files (one for dev and one for
    online-servers).Yes, but they would have the same name. ;-)
    After all when you need to load one
    of them you'd still need in your AppSettings class on
    which server your application is running. So I'd
    still need that information.No, you use a fixed name, e.g. server.properties, for the config file.
    You might find class java.util.ResourceBundle interesting.

  • Message to Creative. Release your RC3 driver for your own car

    I find it quite strange that Creative ship OEM drivers (beta ones) for Prelude series of cards, but totally forgets to release the same driver for its own range of cards. Why I , mean if Auzentech can use them on retail products, I see no reason why Creative can't. Don't you see what's happening out there Are you blind You are loosing peoples trust! C'mon, wake up will you. If a mod or admin could ask this very question to your superiors I would be happy. /G ran A

    The Prelude drivers apparently fixes the 4Gb issue with static sound among other things so there must be some really important changes made into the driver, that's why I'm so puzzled that Creative fails to support its own customers. I know I read somwhere that the president of Creative said that the drivers will be fixed before November this year, he said that it had hurt the sails of cards due to poor Vista support etc. It looks like he might have kicked some butts at the driver departement, so let's have a beta out now to test, please! /G

  • [Desktop][Search] Search Bar for your own music, artist, radios...

    Hi Spotify, when i want to listen a song in my music i have to search it manually. If i not remember de name (of the song, or artist) very well, the search bar allow me it to find it faster.  Ur search bar now only allow me to search the song in the universe, but have another one just for my songs, its gonna be awesome. 

    Updated: 2015-06-30Hi and thanks for your contribution! A similar idea has also been suggested here:
    https://community.spotify.com/t5/Live-Ideas/Search-option-for-quot-Your-Music-quot/idi-p/737701
    Add your kudos and comments there please!

  • Does it cost money to sell your own music that you produced on the iTunes store?

    I have a couple songs of my own that I would like to sell on iTunes. I was looking into it on the iTunes store and it wanted my credit card information. I don't know if this was for the money that I could make to go on, or if it was going to cost me something to put my music on there.

    Hi CarolNonnen,
    Welcome to Apple Support Communities.
    It sounds like you're looking for more information about selling your original content on iTunes. The webpage below will answer your initial questions and help you start selling your content.
    Apple - iTunes - Working with iTunes - Sell Your Content - Music Provider: FAQs
    https://www.apple.com/itunes/working-itunes/sell-content/music-faq.html
    How much does it cost to sign up to offer my content on iTunes?
    Signing up to offer your music on iTunes is free. Additional details on the sales terms are available during the sign-up process.
    I hope this helps.
    -Jason

  • Determining the JMXServiceURL for your own JVM

    Hello.
    I'd like to know how to find the JMXServiceURL of the built-in MBeanServer. In Java 5, I'm using sun.management.ConnectorAddressLink.importFrom(int pid) to determine this, but that means I'm using a non-public, Sun-specific API. In Java 6, we have the new interface javax.management.remote.JMXAddressable, which looks like it might make it possible to find the JMXServiceURL without resorting to a non-public API. However, it isn't obvious how to actually use JMXAddressable to accomplish this goal.
    Can someone explain how to use JMXAddressable to simulate the function of sun.management.ConnectorAddressLink.importFrom(int pid)?
    Thanks,
    -Neil

    I have these concerns about starting my own connector programmatically:
    1. Additional overhead from multiple connectors running. Some applications, like jconsole, may wind up instantiating the built-in connector, too. How concerned should I be about the additional resources consumed by having two connectors? When using jconsole's Threads panel, I see a number of threads associated with the built-in connector, and I don't really have a sense of how busy these threads are. Should I be concerned about this? (I suspect that this isn't a big deal, but I'm uncertain.)
    2. Additional coding complexity. I would want to start the connector programmatically but use an anonymous port. If I'm using an RMI registry, the registry itself would need to use an anonymous port. This means I would need to programmatically create the registry itself with an anonymous port, which as far as I can tell can only be done by creating my own RMI server socket factory which captures the port of the created socket. I then need to manually glue together a JMXServiceURL to register myself in that registry, perform the registration, and then get the JMXServiceURL back. All told, this is at least twice as much code as using the sun.* classes.
    3. Creating an RMI registry is a potential security problem because other applications running on the same host can connect to that registry and replace my JMXConnectorServer with their own. I recall a recent blog about securing the RMI registry against this, but the procedure was fairly complicated, further increasing the coding complexity concern above (concern #2). One thing I haven't explored is the possibility of exposing the JMXConnectorServer via RMI but without using an RMI registry, which may be appropriate here because, given that the RMI registry isn't using a well-known port in my case anyway, it isn't really adding any value. Is it possible to expose the JMXConnectorServer via RMI, on an anonymous port, without using an RMI registry and in a way that allows me to discover what port actually gets assigned to it?
    4. I noticed that if I start my own JMXConnectorServer manually, it prevents my application from exiting. Is the fix for this to simply call the start() method from within a daemon thread, or do I need to ensure that I call stop()? If I need to call stop(), I may need to set up a shutdown hook to do this.
    All told, using the sun.* APIs makes the problem much simpler. I suspect that I may eventually want to move to starting the connector server programmatically, especially as I want to use the security features, but at present the simplicity of the sun.* APIs is too attractive to pass up.
    Thanks,
    -Neil

  • What happened to the default folder set (for your own libraries) in Edit/Preferences, in Adobe Photoshop CC?

    Once again I come to my computer, and it's not the way I left it. While I love cloud, I think in some way, the concept of Customer Service i.e. Providing a Service to a Customer "Set Service, for a Set Price" has lost the value of "service"
    I find it extremely disheartening, to always be dealing with changes Adobe makes, it costs me an exorbitant amount of time. I don't work with a team, so it's just me. And every other week, there is some changes, when my 3D quite working in CS6 I had no forewarning, just woke up one morning and "Poof" no more 3D, the software turned off the feature in my CS6, however, it did work in CC.
    The things I find most disheartening
    features quit working with NO PRIOR WARNING.
    Plug-ins, libraries what, now have to be stored in the cloud in order for MY system to automatically see them?
    Again No Default Libraries on our machines ( unless you think I'm going to store 2 Terabytes of libraries on the cloud and/or in my AppData Directory *not*  Nothing but system/program files themselves go on my Primary drive, everything else is on external drives, this is a security issue and one I'm not about to change, nor should anyone have to change it, since it is a *best practices* standard.
    I still can't access items in (for instance: Color Themes created on Kuler, are available on my computer, but not for me to put them into a library on the cloud. I have over 100 color themes there I have created, on my Creative Cloud account, why can they not be imported or drag/drop into the library designated for it. When I log into my Cloud Account on My iPad it is the same cloud account as on my PC, yet it doesn't even see my previously created color scheme's? Why? Does anyone have any ideas?
    I use a font manager for Windows called High-Logic, a Font Manager, Creator and a Scanner for Hand Writing Fonts Great Program, I've had it for over a year, while there is no plugin for Photoshop there is for In-Design and for Photoshop, I use the Font Manager on my computer to activate the font I want and it shows up in the Character Tool Box automatically.  Yet, just in the last week, every time I try and create something in Photoshop, I'm fine, until I go to use a font, at which time, my working project goes "dark" ( no longer visible) until I click on another tool in Photoshop.
    I cannot keep having these issues, it's way too time consuming, it's exorbitantly time consumer attempting to get a response to questions in the forums (no one's fault, it's just the nature of the forums themselves)
    The true cost of a product is not only in it's subscription based fee, but also includes the time it takes to keep up with product changes, additional training, the cost of delivery (cable connections/provider).  So far since the first of the year I have logged over 100 hours to either 'fix something that quit working with no notice', time spent re-reading documentation seeking a solution, time spent perusing the forums for a solutions, or posting a question, time spent in additional training/books, etc."
    While I understand I'm relatively new, as I had a 5 years off from working, I went from Macromedia Suite 8 to CS5.5 -full suite  (heck-of a learning curve)
    Yet, I cannot believe I am the only person having these issues, otherwise the forums wouldn't be so full.
    I did try limiting the permissions to not allow Adobe to update the software automatically, however, the permissions I wrote, were in fact re-written by adobe's cloud synchronization, Which I did find disturbing on a few levels. None of which I'll go into, but it needed to be mentioned that *yes, I tried that too*.
    *I ended up re-configuring my machine AGAIN* and deleting CS6 altogether, The performance change after I deleted CS6, was/is the difference and why I am still with my cloud membership.
    **I have reconfigured my machine numerous times, to facilitate the cloud, I am on a PC, Adobe and Microsoft Development Environments do not play well together, I ended up removing them altogether and creating a vm for them and basically all my development work. And have twice since reconfigured it for various reasons.

    Hi
    One of the reasons that Edge fonts and web fonts are though to be preferable to the old font stacks was because of Android tablets/smartphones only having the Droid font family available, (Android 4.3 added the Roboto font family also).
    This meant that Android device users defaulted to the 'Droid' font or a user installed font. The default font if the user had installed a custom font and set it as default, could be anything, (even a comic script font) thus possibly destroying your text and/or layout completely.
    If you are not using an Edge font or a downloadable font do not forget to set the last three fonts in your font stack to -
    '...., Roboto variant, Droid variant, default font'
    PZ

  • HT201304 If you set restrictions to on for your ipad or iphone & you set the password restriction to immediately for in-app purchases will it ask you for your password every time you make a purchase over a certain time period or just the first time you us

    I am setting restrictions on my iphone and my ipad for my four year old son as he somehow purchased an app for $99 unbeknowst to me.
    Does anyone know if you set your restrictions to ON, there is a setting that is called "Require Password" and there are two choices to choose from
    "immediately" or "15 minutes". What I want to know is if my son asks me to purchase an app that costs $1 and I let him purchase it. Be entering my passcode
    will it not ask him for any future purchases or an in-app purchase where they tend to rip you off. I want to ensure that it asks for a password every single time anything is purchased whether it is an in-app purchase or an app. I am unsure what the difference is between choosing immediately or 15 minutes on this specific Restrictions setting. Thank you.

    Settings>General>Restrictions>Allowed Content>In-App Purchases>Off. Then: Settings>General>Restrictions>Allowed Content>Require Password...set this to "Immediately".
    Doing the above will accomplish what you want.

  • Hi. Is it possible to get same photo tittle front as iTunes movies has with your own dvds when you'r using iTunes?

    I've bought "In Time" from the Itunes store, but is it possible to make the other movies I have from my DVDs look the same as the one I've purchased online?
    -Hope I've explain my problem so it's to understand hehe?...
    Hope there's someone who can help me.
    Thanks in advance.
    Christian Kofod.

    You can add any artwork you want to your movies using the artwork tab of the get Info window in iTunes (CMD + I)

  • When you change the password for your apple Id and you loose all your messages can you get them back?

    So my stupid mum decided to change the password instead of waiting for me to get up -_- and now I have lost all my iMessages that were very important and I can't find them I recently tried to back all my iPod up to my laptop but I had a look and couldn't find anything to do with messages can someone help

    You only way is to restore from backup if you have backed up after the Messages were on the iPod but before you "deleted" them. iTunes only retains the last backup.
    See the restore topic of:
    iOS: How to back up

  • HT201303 how do you reset the security question answers for your itunes account if you have forgotten them?

    I have forgotten the answers to my itunes security questions, how do i rest them?

    Welcome to the Apple Community.
    Start here, and reset your password, you will receive an email with your new password, then go tomanage your account > Password and Security and change your security questions.
    If that doesn't help you might try contacting Apple through iTunes Store Support

Maybe you are looking for

  • Install Guide - SQL Server 2014, Failover Cluster, Windows 2012 R2 Server Core

    I am looking for anyone who has a guide with notes about an installation of a two node, multi subnet failover cluster for SQL Server 2014 on Server Core edition

  • Error while starting Integrated weblogic server

    Hi All, I have installed Jdev11.1.1.4 in a new XP system. when i am trying to run any application or starting the server instance of Integrated weblogic server i am getting below error. Caused by: java.lang.ClassNotFoundException: Data\JDeveloper\sys

  • Mac mini restarts on its own after shut-down.

    The Mac mini will restart by itself about 10 minutes after shut down. I turned off all the restart options in energy saver. Funning 10.4.8 with the latest firmware instalation. Any suggestions how to stop this?

  • LG 29" Ultrawide sharpness question

    I am not really sure if this is a Mac Pro issue, a Mac OS X mavericks issue, a Window 8.1 issue or the LG itself!  Hence why I have no idea where to post this.  I'm hoping someone will happen upon it that knows more than I do, and give me a clue to w

  • Scene Detection on Capture?

    Primere Pro has an option when capturing "scene detection", makes capturing individual clips easy and fast. I would think there's a similar feature in FCP 5.1?