Interface design V class design

Why is it more important for an interface design than for a class design to anticipate all possible uses for the interface?

come on.. I was gonna do this
//interface
interface IshouldBeSleeping
public void IamSadistic();
class WhyAreWeAnsweringThis
public double habitualProcessOfWorkingForLameCurrency
   return 0.0001;
}

Similar Messages

  • Question about view/controller/nib class design

    Assume you need to make an application with, let's say, 15 different views in total. There are two extreme design choices you can use to implement the app:
    1) Every single view has its own view controller and a nib file. Thus you end up with 15 controller classes and 15 nib files (and possibly a bunch of view classes if any of your views needs to be somehow specialized).
    2) You have only one controller which manages all the views, and one nib file from which they are loaded.
    AFAIK Apple and many books recommend going purely with option #1. However, going with this often results in needless complexity, large amounts of classes (and nib files) to be managed and complicated class dependencies, especially if some of the views (and thus their controllers) interact with each other or share something (something which would be greatly simplified if all these related views were handled by one single controller class).
    Option #2 also usually ends up being very complex. The major problem is that the single controller will often end up being enormous, handling tons of different (and usually unrelated) things (which is just outright bad design). This is seldom a good design, unless your application consists of only a few views which are closely related to each other (and thus it makes sense for one single controller class to handle them).
    (Option #2 also breaks the strictest interpretation of the MVC pattern, but that's not really something I'm concerned about. I'm concerned about simple design, not about following a programming pattern to the letter.)
    A design somewhere in between the two extremes often seems to be the best approach. However, since I don't have decades of Cocoa programming experience, I would like to hear some opinions about this subject matter from people with more experience on that subject. (I do have object-oriented programming experience, but I have only relatively recently started programming for the iPhone and thus Cocoa and its design patterns are relatively new to me, so I'm still learning.)

    Somehow I get the feeling that my question was slightly misunderstood.
    I was not asking "which one of these two designs do you think is better, option #1 or option #2?" I already said in my original post that option #2 is bad design (unless your application consists of just one or two views). That's not the issue.
    The issue is that from my own experience trying to adhere very strictly to the "every single view must have its own view controller and nib file" often results in needless complexity. Of course this is not always the case, but sometimes you end up having controller classes which perform very similar, if not even the exact same actions, resulting in code repetition. (An OO'ish solution to this problem would be to have a common base class for these view controllers where the common functionality has been grouped, but this often just adds to the overall complexity of the class hierarchy rather than alleviating it.)
    As an example, let's assume that you have a set of help screens (for example one help screen for each major feature of the app) and a view where you can select which help view to show. Every one of these views has, for example, a button to immediately exit the help system. If you had one single controller class managing these views, this becomes simpler: The controller can switch between any of the views and the buttons of each view (most of them doing the same things) can call back actions on this controller (eg. to return to the help selection or to exit the help screen completely). These help screens don't necessarily have any functionality of their own, so it's questionable what do they would need view controllers of their own. These view controllers would basically be empty because there's nothing special for them to do.
    View controllers might make it easy to use the navigation controller class, but the navigation controller is suitable mainly for utility apps but often not for things like games. (And if you need animated transitions between views, that can be implemented using the UIView animation features.)
    I also have hard time seeing the advantages of adhering strictly to the MVC pattern. The MVC pattern is useful in things like web servers, where MVC adds flexibility. The controller acts as a mediator between the database and the user interface, and it does so in such an abstract way that either one can be easily changed (eg. the "view", which normally outputs HTML, could be easily changed to a different "view" which outputs a PDF or even plain text, all this without having to touch the controller or the model at all). However, I'm not seeing the advantages of the MVC pattern in an iPhone app. It provides a type of class design, but why is it better than some other class design? It's not like the input and output formats of the app need to be changed on the fly (which is one advantage of a well-designed program using the MVC pattern).

  • Need help with design with classes, etc...

    Hello Experts,
    I am currently doing a report which gets data from several tables then processing it and showing it
    via ALV. Now, I am kinda confused as to how to declare the classes meaning do I group
    all the fetching of data to 1 class(e.g. method 1 to get data from MARA, method 2 to get data from marc, etc)
    then create 1 class to process/combine the data and another class to display the data via ALV?
    for example:
    class data_definition abstract contains all the general data declarations
    class get_data contains methods for fetching data and inherits data_definition class.
    class process_data contains methods for combining and manipulation of data and inherits get_data class
    class display_data contains all the SALV classes and inherits data_definition class
    Please recommend a better option for my design.
    Thank you guys and take care!

    Hi,
    I think it really depends on approach you choose. You can leave the design as it is, or group it all in one class. As long as you are working on same data, it must be visible in all classes (which you achieved by defining data_definition class). Alternatively to this you could create an interface and each class could implement it, this way global data would stay visible in all classes. Only interface components addressing would change a litte bit. As for fetching and processing data you can write separate methods for it, get_ , set_ respectively. Anyhow, I think important is to have clear understanding what your class is responsible for, so that logically data contained in it create some encapsulated entity.
    Please also note that good practise for classes comunication would be using events instead of explicit call of public methods. You can consider that too. Also try to think the way as you would be comming back to this programm after a while. Is it clear for me enough? Do I understand exact purpose of each class, their methods? Do I have any data which are defined twice or three times (reduntant data)?
    I think such questions will lead you to the answer: "Yes my approach is the best one I chose", or, "I have to think about better OO desing before starting my coding".
    All in all it turns out that some things have to be changed during coding and sometimes it requires a small backward rebuilts.
    Regards
    Marcin

  • Design and class dependency

    Hi
    I have a hard time putting a program together when it consists of many classes. I put a big effort in making a good class-design but I don’t think I really get it. I have read a lot of design patterns, but in the end I always get confused about how the ‘view’ and the ‘model’ have to communicate with each other.
    Here is a image which describe my problem
    image
    The only way I can get this working is by having a big ‘control’ class where I get and set everything.
    Ex. If I want to put a grid in PanelB:
    Tile t = loaddata.getCalcOnData().getGrid().getTile();
    guiFrame.getPanelB().setTile(t);
    I don’t think this is right, but how can I else make the MVC pattern work?

    The image is blocked from me at work, so I could not refer to that. Based on the descriptions you provide, I am guessing this is a Swing app. However, the points below apply generally to a web application.
    Your model is simply whatever you want. You should not have any controller or view aspects to your model, ideally. The model is what makes your system unique. You can write procedurally with immutable data transfer objects, use Java beans or some combination. Try to follow your best OO practices here when it is possible.
    Your controller and view completely depend on one another. Basically, the controller is responsible for invoking model functionality (or services), taking the results and dispatching (or providing) them to a view. The view takes those objects and renders a display. The view also sends user events (mouse clicks, keyboard input, web form posts, etc.) to the controller, and the whole beautiful process repeats itself.
    So, at the end of the day, the model is basically easy to understand. The view is also easy to understand. What trips most people up is the controller.
    For Swing, you basically add listeners to your various view components. So, you have a listener for a button click, a listener if a list box values changes, etc. As many as you want or need. These listeners do not have to do anything fancy. They simply have to validate (and maybe transform) the event they receive and send the data portion (method arguments, etc.) to a model object.
    On the "return" trip, most model methods will return some data to the view . The controller is responsible for forwarding this response on to the original view or to another view (e.g., button click refreshes a page versus button click navigates you to the next screen in a wizard).
    You have a lot of freedom in your controller's design. It really does not have to look pretty. It simply has to "glue" the view components to the model. But understand, the model exists, ideally, on its own. You should be able to have the same model be re-used in other scenarios (e.g., a swing view, a web app view, etc.) The controller and the view are intimately related. It is possible to write "abstract" or "generic" controllers, but IMO, this is definitely not worth the effort until you have multiple views to service. If you are interested in decoupling to this extent, take a look at the Command pattern.
    One final thought, take a look at Spring MVC. Their controller's method signature probably makes the MVC concept as clear as possible:
    http://static.springframework.org/spring/docs/2.5.x/reference/mvc.html
    public interface Controller {
         * Process the request and return a ModelAndView object which the DispatcherServlet
         * will render.
        ModelAndView handleRequest(
            HttpServletRequest request,
            HttpServletResponse response) throws Exception;
    }http://static.springframework.org/spring/docs/2.0.x/api/org/springframework/web/portlet/ModelAndView.html
    Hope that helps.
    - Saish

  • What happened to class designer and printing in JDev 9i??

    Where did the "Class Designer" go in JDeveloper 9i... It was in JDev 3.2??
    Also, I've read that the printing functionality will be put back into JDeveloper in the next release. It there a date set for this release?
    Thanks

    Are we still another release away from getting the printing functionality back?? I just downloaded 903 and it still doesn't have all the printing functionallity that 3.2.3 had?? What happened?
    Bret
    Where did the "Class Designer" go in JDeveloper 9i... It was in JDev 3.2??In JDev9i, the editors are seperated, so right-click in your code editor, and select Class Editor.
    Also, I've read that the printing functionality will be put back into JDeveloper in the next release. It there a date set for this release?Unfortunately, we don't have a firm date yet for the next release.
    Rob

  • Chart Interface In web application designer?

    Hi experts:
          I want to know if there is chart interface in web application designer?when i click a node in the chart ,it can triggle a js to jump to another page to show the detail? how I can do it?
         I think there do have method to implement,as when I put the mouse on the node of the chart ,the "javascipt:;" shows in the status bar of the IE ,I don't know where can I write the JS ?
    Best Regards
    chan.

    Hi Chan,
    1. You type tcode RSBBS in BW system
    2. Under Query Tab, there is 'Sender' field. You input the the origin query.
    3. Click 'Create' button, you choose the report type that you want to jump into. In you case, if you want to jump into a web template, choose 'BW Web Application'
    4. In 'Report' field, choose the destination query/web template.
    For more details, please look at this link
    http://help.sap.com/saphelp_erp2004/helpdata/en/c9/bc2d38c4b3f205e10000009b38f8cf/content.htm
    Hope it will help.
    Cheers,
    Mona

  • Unable to use Class Designer when deriving Entity Bean from another class

    I have several Entity Beans that have common fields. In order to maximise reusability, I have defined a base class which contains these common fields and corresponding get/set methods on these fields.
    In the next step, I build an Entity Bean using JDeveloper. I then go to Source Editor and in the Bean class, modify the Java code to inherit from this base class that I have defined. I then try to go to Class Designer expecting to see the inherited fields as well.
    However, this is the error I get :
    "Error while trying to parse source file...."
    Any pointers on resolving this would be a great help ! Thanks !!!
    -Andre
    null

    If you're running >Java 1.4, you'll need to put your classes into a package since Tomcat can no longer import the class 'BeanProdess' which is in an unnamed namespace.
    Your JSP is compiled into a class (in the package org.apache.jsp) that doesn't recognize anything in the default package.
    Here's a reference if you want to read about this.
    http://java.sun.com/j2se/1.4/compatibility.html#incompatibilities1.4

  • Controlling user interface settings on LiveCycle Designer ES4

    How can you control the user interface settings on LiveCycle Designer ES4?

    The problem you descibe has nothing to do with the PDF security settings.
    If you have added scripts in the fields calculate event or set their access property to readOnly or protected you won't be able to change a fields value.
    Ypu can check the current access setting in the Object palette under the Value tab.

  • Pattern b/w Remote interface & Container implementation  class

    Which pattern is followed by EJB Remote interface & Container implementation class of that interface?Is there anyting mentioned in specs?
    This questoin was asked to me by many people.I think it is Command design pattern as it hides away all the details of actual business implementation.but at same time I doubt if it is Facade?
    Anyone who knows about this?
    Thanx in advance
    Sidhu

    Rarely is software represent a single pattern, it typically represents multiple patterns.
    Which pattern is followed by EJB Remote interfaceThe remote interface is an example of a facade pattern. This presents a public interface which is an abstraction of the real interface.
    Container implementation class of that interface? The implementation is an example of what I think of as a double proxy pattern. That is acting as two distinct proxies. The first being the the remote callingof EJB standard functions via the Skelton implementation. I.E. The underlying EJB/RMI interface. The Second being a application level proxying of the business logic seen in most RL implementation.
    The use of an UID ID beans is an example of a memento.
    I think it is Command design pattern as it hides away all the
    details of actual business implementation.Not directly, though an AppServer programmer may use the Command Pattern to resolve the remote connections. The User Application Programmer may also use this pattern. The key element of Command Pattern is the Invoker executing an concrete class via abstraction or interface of a polymorphic class. You can think of this as a specialisation of the
    Martin

  • Whats the difference between an INTERFACE and a CLASS?

    Whats the difference between an INTERFACE and a CLASS?
    Please help.
    Thanx.

    http://search.java.sun.com/search/java/index.jsp?col=javaforums&qp=%2Bforum%3A31&qt=Difference+between+interface+and+class

  • How can i change an interface to a class?

    I created an interface with name XXX.
    But when i have finished and saved it,i learn the XXX was not an interface but a class.
    Then i delete the interface XXX in SE24,and creat it for a class with the same name XXX.
    But wrong message occur " There is already an object directory entry: R3TR INTF XXX".
    How can i solve the problem and creat the class with name XXX?
    Thank you very much~~

    1)Tr-cd SM30, Table/View 'TADIR', Display.
    2)Selection by Objects, Check and Input 'R3TR', 'INTF' 'XXX' .
    3)Cursor 'XXX'.
    4)menu->Objects->Delete Object Directory.
    5)Retry Tr-cd SE24.
    You should start the interface by 'Z_IF_xxx' or 'Y_IF_xxx'.

  • Interface and Inner Class

    Hi,
    In interface we can't provide method body.
    but we can provide method body like this,
    public interface TestInterface {
         public class Add {
              public int add() {
                   return 100;
    what is the logic behind Inner Class inside interface.
    plz help.Thanks in advance.

    there isn't really any logic to it, it's just something that's semantically possible. there wasn't a conscious decision to allow this, it's just a by-product of the enclosing types mechanism, and while it wouldn't be a good idea to do this, there's no technical reason why it shouldn't be possible, either

  • How to create an interface if the class has a nested class

    I have the following class
    public class SampleImport{
    public SampleResult import (InputSource xml) {
    SampleResult sampleResult = new SampleResult();
              //do something
              return sampleResult;
    public static class SampleResult {
              public final String sampleName;
              public SampleResult (String s) {
                   sampleName = s;
    I would like to create an interface for this class for teh following method signature 'SampleResult import(InputSource(xml))', how would I create it ?
    Any help is appreciated,
    TIA,

    public interface Nameable {
        String getName();
    public interface Importable {
        Nameable importSource (InputSource xml);
    public class SampleImport implements Importable {
        @Override public SampleResult importSource (InputSource xml) {
            SampleResult sampleResult = new SampleResult("foo");
            //do something
            return sampleResult;
        public static class SampleResult implements Nameable {
            public final String sampleName;
            public SampleResult (String s) {
                sampleName = s;
            @Override public String getName() {
                return sampleName;
    }edit: er, you do know import is a keyword?

  • Report Designer  and Query Designer in BI 7.0

    Hi friends,
          what is the use of  Report Designer  and Query Designer.. and what is the difference between  these two..
        I know about  Analyser... that is used for designing a query and we can analyse (or) see the result of that query in that  window....
         then what is  the use of Query Designer... can you  give me the brief  introduction abt that...  if any documents plz farword  to me..
    my mail id--- [email protected]
    thanks
    @jay

    Hi Ajay,
    Report Designer is a newly added feature in BI 7. This helps to do cosmetic changes to the report, change the fonts, add colors etc. Please check this link for more info on Report designer.
    http://help.sap.com/saphelp_nw04s/helpdata/en/17/16d941de405f24e10000000a1550b0/frameset.htm
    Query Designer, is where you develop, edit your queries.
    Analyzer, is where you execute the query and analyze the results.
    Hope this helps.

  • Difference between interface pool and class pool

    Hi,
    Can any body tell me the difference between Interface pool and Class pool.
    thank you in advance.
    regards

    Hi,
    Class and Interface Pools
    This section discusses the structure and special features of class and interface pools for global classes.
    Global Classes and Interfaces
    Classes and interfaces are object types. You can define them either globally in the Repository or locally in an ABAP program. If you define classes and interfaces globally, special ABAP programs called class pools or interface pools of type K or J serve as containers for the respective classes and interfaces. Each class or interface pool contains the definition of a single class or interface. The programs are automatically generated by the Class Builder when you create a class or interface.
    A class pool is comparable to a module pool or function group. It contains both declarative and executable ABAP statements, but cannot be started on its own. The runtime system can create runtime instances (objects) through a request using the CREATE OBJECT statement. These objects execute the statements of the class pool.
    Interface pools do not contain any executable statements. Instead, they are used as containers for interface definitions. When you implement an interface in a class, the interface definition is implicitly included in the class definition.
    Structure of a Class Pool
    Class pools are structured as follows:
    Class pools contain a definition part for type declarations, and the declaration and implementation parts of the class.
    Differences From Other ABAP Programs
    Class pools are different from other ABAP programs for the following reasons:
    ·        ABAP programs such as executable programs, module pools, or function modules, usually have a declaration part in which the global data for the program is defined. This data is visible in all of the processing blocks in the program. Class pools, on the other hand, have a definition part in which you can define data and object types, but no data objects or field symbols. The types that you define in a class pool are only visible in the implementation part of the global class.
    ·        The only processing blocks that you can use are the declaration part and implementation part of the global class. The implementation part may only implement the methods declared in the global class. You cannot use any of the other ABAP processing blocks (dialog modules, event blocks, subroutines, function modules).
    ·        The processing blocks of class pools are not controlled by the ABAP runtime environment. No events occur, and you cannot call any dialog modules or procedures. Class pools serve exclusively for class programming. You can only access the data and functions of a class using its interface.
    ·        Since events and dialog modules are not permitted in classes, you cannot process screens in classes. You cannot program lists and selection screens in classes, since they cannot react to the appropriate events. It is intended to make screens available in classes. Instead of dialog modules, it will be possible to call methods of the class from the screen flow logic.
    Local Classes in Class Pools
    The classes and interfaces that you define in the definition part of a class pool are not visible externally. Within the class pool, they have a similar function to local classes and interfaces in other ABAP programs. Local classes can only be instantiated in the methods of the global class. Since subroutines are not allowed in class pools, local classes are the only possible modularization unit in global classes. Local classes have roughly the same function for global classes as subroutines in function groups, but with the significant exception that they are not visible externally
    Reward points if useful....
    Regards
    AK

Maybe you are looking for

  • Add values to one variable in a loop

    Hello, I have a while loop where I read a counter and get values. Now I want to add all values to one variable. I think an array won't be good because the loop can run a long time and an array is limited. And the end I want to have the sum of all val

  • Vendor Consignment Clearing

    Hello Experts, Can you plese explain/show me the process of clearing consignment related GR/IR up to accounting? As from what I'm thinking, before the documents can be cleared in transaction F.13, it must be first cleared on the MM side. Because docu

  • Service sapdp01 timed out

    Hi people, Firt my apologizes if this is not the corresponding forum to post this error. I didn't know where i should post it. When i try connect through sap logon i have this error: Connection  to host XXXXX service sapdp01 timed out. In services fi

  • Unicode in Java Applet

    Helo, -> I want to build an applet which has to display unicode. -> my applet will be similar to a soft keyboard. -> Please let me know how to bring unicode characters on buttons and lables. Its really urgent. hoping for the solution

  • Popu window before session timeout

    I am trying to display a session expiration message first when the session times out before. I have write some code - SessionListener.java - in which we create xml file when session is created and deleted when session is destroyed,. A structure of xm