Question in design

Hi,
I am writing SMTP server in java as final project in programming course, the server uses the state and command patterns.
in each state the server can only process specific SMTP commands which are encapsulated in a Command object.
(Not a code,rather a pseudocode):
public interface ICommand
     public ISMTPSession getSession();
     public String Execute();
class SMTPCommand implements ICommand
some common stuff for all commands
class HELOCommand extends SMTPCommand
class InitialState extends SMTPState
     InitialState()
     //Can handle HELO only
     String ExecuteCommand(ICommand command)
          //Must be HELO only
          if(command is HELOCommand){
               return "error";
          return command.Execute();
The state must know what kind of command it deal with so I am querying the interface for the concrete class type.the problem is that other user can implement their commands, for example
Class HELOCommandEx implements ICommand
This will cause the following line to always fail
if(command is of HELOCommand){
               return "error";
The simplest solution is to add a function to the ICommand interface which
Will return the SMTP command name
public interface ICommand
     Public String getDescription();//return the SMTP command name
     public ISMTPSession getSession();
     public String Execute();
Is there a better way to do it in java?
Thanks in advance

You could replace ICommand by an abstract class with package-private constructor, so users can't override it. If you make your basic Commands (like HELOCommand) accessible via public classes or interfaces, all users implementations will inherit from these basic types, not only from ICommand - and your type checking will work.

Similar Messages

  • A question about design of Java Application on java card.

    Hi every one,
    I have a question about design of Java applet on java card,
    There is an application on my card that it is not java card, it include a DF and some EF under DF, I would like to know if I want to have this application on java card ,how can I design DF and EF on java card ,I mean is there any relation between DF,EF with applet and file? for example can I say DF is same as applet and EF is same as file?
    I'll appreciate for any help .
    yours sincerely,
    orchid

    hi
    you can write a java class for DF.
    an instance of DF class have some EF objects.
    for example,
    samples/com/sun/javacard/samples/JavaPurse/CyclicFile.java
    implements ISO 7816 CyclicFile ( EF )
    see also:
    http://forum.java.sun.com/thread.jspa?threadID=673745&messageID=3936272
    best regards,
    siavash

  • A Set Of questions on Designer

    Hi,
    I have a customer issues where-in I need help in answering below mentioned questions.
    Its a very high priority customer & need answers urgently.
    Can any one help me in this regard.
    Questions Below
    1) I assume the meta-meta model has expanded to handle new Oracle features.
    A quick look at a diagram labeled sdd_elements designer_6i-9i_Model suggests that the basic
    model has not changed. I would like to confirm this. I would also like to see what elements are now supported. A listing of the name column from the element_type table would give me this. This table is
    recursive. A recursive list that shows subtyping would be ideal but is not critical.
    2) Is the API still fully supported? When the API was initially published all of the screens in the designer tool were revised to use the API. Is this still the case?
    3) What diagrammers are supported? At one time there where plans to allow users to customize and extend diagrammers. Has this ever happened? The automatic layout functionality of the data model
    diagrammer used to be very primitive. Have they been improved? I have been hoping for options that would prohibit knees in FK lines, that would prohibit diagonal lines and that would prevent line through boxes.
    4) How complete is reverse engineering?. Can I reverse engineer a database and then forward engineer the complete database including the create database, create control file and create tablespace statements.
    Can I reverse engineer from older Oracle versions (8 and 9). Can I reverse engineer with the source on another machine via SQL*Net.
    5) How complete are the Configuration Management components? How complete is the impact analysis?
    What non-Oracle sources are supported by impact analysis? Can any of these non-Oracle sources be incorporated into the Configuration Management.
    6) Are there direct links from Oracle to 3rd party configuration management tools? I believe we will be using PVCS.
    Thanks in advance.
    Regards,
    Nagadeep

    Hi Laura,
    Eventhough the code is not difficult, there's no sample for that. The procedure is well described in the following lines, that i took form thread few questions....
    1. On 2005 version you can use the Grid & Data Table in cases you want to show query result - the Data table allows you to write open SQL query statement (use the "order by" in it) & the Grid automatically refreshed with the query result data (columns & rows).
    On 2004 – The DBDataSource does not contain sorting capabilities… the only way is to fill the DBDataSource manually from sorted record set, bind it (column by column to matrix on the form) and load it from the data source (activate Matrix::LoadFromDataSource). The manually filling will cost – but I cannot see better solution for it under DBDataSource).
    Perhaps after you tried it, you can share the code :o)
    Best regards,
    Felipe

  • Questions about  Designer

    Hello,
    I am new in this forum and in Oracle Designer also.
    I have started to work with Designer last month,
    I am learning to use it,
    and I have a question :
    - what is the difference between Template object and object library???? waht ares the uses of both them ?
    - waht is the difference between Designer et Designer headstart?
    thanks for your help ans have a good day,

    I'll give you my opinion based on my experience...
    Templates serves as 'skeletons' of generated forms and reports. You use them to define global appearance and functionalities of the module, but not details like specific item properties.
    The object libraries define the details of the generated objects, like items, canvas, windows. Many properties you can't define using templates, but can do using object libraries.
    Usually to generate an app you rely on both templates and object libraries, as well on preferences.
    I've never used headstart, but I think it's a kind of "add-on" to Designer, with pre-customized templates, object libraries etc (maybe it can be thought as a framework?)
    hth

  • Simple Design Analysis Question before designing dimensions and facts

    Hi I have a simple question ... (I think its simple)
    Suppose that i have the following staging table with the following columns:
    Student_Name | RollNo | Test_Date | Subject-Taken
    with data such as
    Kevin |123|12-4-2010|Physics
    now suppose that I want to design a cube on the basis of the above table so that I can succesfully get the result of a query such as
    List the names of all those students who took the test b/w 12-4-2010 to 12-5-2010 of the Subject Physics
    Here what i need to know what dimensions/Levels would u set and what would be our fact?
    I think that one dimension would be time ( but i am not sure how i would  accommodate and handle duration... any idea )
    would it be wise to make each column a dimension ??? for example the student_nanme a dimension and details of the student its attributes??
    Anyways the main thing is what bothers me is looking at the query we see that we are required 3 things the name of the student , the TestDate and subject taken so if i make the 3 columns the  dimension i am still not sure that i would be able to acomodate the query properly...any ideas on how to approach and handle these situations
    Edited by: Johnacandy on Dec 14, 2010 9:26 AM

    ScoobySi wrote:
    Yes I mean Time dimension, however in a DW you will have many Time dimensions, instead of creating a physical object for each you use a ROLE. If you edit a dimension in OWB you'll see that you can specify a ROLE on the first tab.
    Thanks for the great explaination... could you explain the process of roles a little more that will really save me some time... furthermore u stated
    + "instead of creating a physical object for each you use a ROLE" +
    The way i create dimensions is right clicking dimensions and selecting dimension.... for a standard dimension
    however incase of a time dimension i use a wizard... I am still a bit confused about "Physical objects" ... Id really really appreciated it if you can clarify this up...
    as discussed before one dimension would be Student and other would be subject
    and 3rd one would be TEST_DATE with role ?? and should that be a time_dimension or a standard dimension with a role defined ???

  • Question + Adobe Design Premium CS3 Problem

    Question:
    When I boot up Leopard after the grey apple logo loading screen it will turn to the blue screen then directly to my desktop. In tiger it would go to the blue screen then you would see a window with a loading bar. Did they remove that in Leopard because I don't see it, it just goes directly from the blue screen to my desktop.
    Adobe Design Premium Problem:
    I installed Adobe Design Premium CS3, I got some functionality problems so I deleted it from my Applications folder to re-install the trial software as I was in a hurry to get InDesign working because I had an assignment due. When I tried to install InDesign CS3, it would tell me during the installation that I can't install it because of "Adobe InDesign CS3". I am assuming that it still thinks that InDesign CS3 is installed? I made sure that I had deleted all the Adobe software from my computer. It did this with my other applications too when using my CD to install Design Premium again. It's like I'm locked out of installing it? I've heard of other people having the same problem.
    Any suggestions?
    Thanks.
    Message was edited by: J33v4n

    If there isn't an answer, it usually means other users don't know the answer.
    As far as the Adobe suite goes, there are two steps to deleting the suite. The first is deactivating it (I think that's on the Help menu), and the second is running the installer with the Uninstall option so that all of the files it installs in various places are removed. Is that how you did it, or did you just throw files in the Trash? If you trashed them manually, there are probably pieces left behind that are getting in the way.
    That is all I know about that one. For potentially much more information, you should drop by the Adobe user forums, where there should be many more users with direct experience with the Adobe-specific install/uninstall issues. Try clicking on the "Creative Suite" forum there.

  • Question about design - use patch-panels or switches in racks?

    I'm trying to suggest should I use patch-panels in server 19" racks and use stand-alone telecomm racks for access layer switches
    OR
    should I install 2-3 access layer switches in every server rack?
    First version looks more correct, but than I have to use MUCH MORE cables, organizers etc - all of it eats place in data-center.
    Maybe someone saw some guides for that question?
    Thanks!

    2 or 3 access layer switches in every server rack? Considering typical stand-alone rack switches offer 24 or 48 ports, how many servers per rack or how big are these racks?! Or, were your intended access layer switches only 4 port switches?! (laugh)
    The main disadvantage of rack switches, you either run out of ports or have too many ports. Since server hosts often push bandwidth harder than user hosts, you also have the issue of how much aggregate bandwidth you need to move out of an individual rack. These issues are better addressed by your suggestion of using patch panels from each rack that come to a network switch rack.
    You're correct, all the cables, and their organization, has an expense, but this has to be considered against switch costs. Assuming you intend to use Enterprise switches that offer gig to the servers and perhaps 10 gig uplinks, there's a cost to having extra swiches by deploying to each rack. Also switches per rack would disallow the advantages you might find with a chassis switch in a switch rack. Further, depending on performance to provide, do you want to be limited by uplink bandwidth from each rack, or pay for high bandwidth from each rack that's usually underutilized.
    Besides "looking right", the foregoing is often why there are server rack patch panels, etc.
    One design, that I found interesting, was using the 3750 "stacked" across racks (guess you could do same with newer 2975s).

  • Question about Design Standard licence

    Hi!
    I would like to know, when you buy a licence Design Standar, this is only for one computer or you can install it on 2?
    I'm trying to understand also about volume licence.. This is useful only when you have how much computer? we are going to have maybe a maximum of 6 computer using that suite.
    Thanks!
    Christ

    Hi Christ, here's an overview guide to answer all those questions and more on Adobe volume licensing...
    If not, just post back with anything further.

  • Question about design pattern - business delegate

    hi guys
    i have got a question to ask about the delegate pattern. usually, we use it to decouple between presentation client and businessservice tiers. for instance, the service tier has an session ejb, and delegate wrapps the ejb. and the web client calls delegate to access service. is the delegate only used by the presentation tier? within the service tier, we can have many ejbs that work together to get tasks done. do we still use delegates in the service tier? what is ur suggestion? thanks

    Try the Patterns and OO Design forum.

  • Question on design of new layer comps feature

    The new layer comp feature in Photoshop CC 2014 is great. It allows you to access the layer comps within smart objects from another file.
    One very important aspect seem to have gone missing though: Imagine you have 1 master document (e.g. website mockup) with several smart objects inside it (e.g. popup menus). Each of the smart objects have layer comps (e.g. folded / unfolded states) that I can access from the master document. Great!
    Now I want to save a layer comp in the master object that reconfigures layer comps on the various sub smart objects (e.g. showing menus opened/closed). This doesn't work.
    The reason it doesn't work is that a "published" layer comp on a smart object is a property of the smart object. A layer comp can only save visibility/layer styles/position but not properties. So I am forced to manually change the layer comp of all my included smart objects in order to reach the target look of my master document. This makes the feature much less useful.
    Am I missing something? It seems like such an obvious feature to have. Have you considered this when you designed the layer comps feature? Will it be an upcoming feature?

    I have the exact same problem. I thought this was the whole point of smart objects with layer comp states. Without this feature it seems pointless. 
    Avoiding having multiple layers is the reason you would use this. Now all we achieve is having smart objects instead of folders. Pretty ridiculous I must say.
    It even seemed from the presentation of the "new and improved layer comps" that you could do this. They skip that specific functionality, but it seems implicit in the presentation.
    Other thing is that the update position, style and visibility are buggy as hell. And another obvious feature of updating text-fields is missing as well.
    So we have to find plugins to help us. BUT cc 2014 doesnt allow for flash plugins and no HTML5 plugins are available. Thank you Adobe!

  • Questions VLAN design best practices

    As per best practices for VLAN design:
    1) Avoid using VLAN 1 as the “blackhole” for all unused ports.
    2) In the local VLANs model, avoid VTP (use transparent mode).
    Point 1
    In a big network, I'm having VLAN 1 as the blackhole VLAN. I'd like to confirm that, even if we're not complying with best practices, we're still doing fine.
    a) all trunk ports on all switches have the allowed vlans explicitly assigned.
    b) about all ports on all switches are assigned to specific data/voice vlans, even if shutted down
    c) the remaining ports (some unused sfp ports for example) are shutted down
    d) we always tag the native vlan (vlan dot1q tag native)
    So, no data is flowing anywhere on VLAN 1. In our situation, it is safe to use VLAN 1 as blackhole VLAN?
    Point 2
    Event if we're using local VLANs model, we have VTP in place. What are the reasons of the best practice? As already said, we allow only specific VLANs on trunk ports (it's part of our network policy), so we do not have undesired layer 2 loops to deal with.
    Any thoughs?
    Bye
    Dario

    We are currently using VTP version 3 and migrating from Rapid-PVST to MST.
    The main reason for having VTP in place (at least for use) is to have the ability to assign ports to the correct VLAN in each site simply looking at the propagated VLAN database and to manage that database centrally.
    We also avoid using the same VLAN ID at two different sites.
    However, I did find something to look deeped: with MST and VTP, a remote switch can be root for a VLAN it doesn't even use or as active ports into, and this doesn't feel right.
    An example:
    1) switch1 and switch528 share a link with allowed vlan 100
    2) switch1 is the root for instances 0 and 1
    4) VLAN 100 is assigned to instance 1
    5) VLAN 528 is not assigned to any particular instance so it goes under instance 0
    6) VLAN 528 is the Local Data LAN for switch528 (switch501 has VLAN 501)
    swtich528#sh spanning-tree vlan 528
    MST0
      Spanning tree enabled protocol mstp
      Root ID    Priority    24576
                 Address     1c6a.7a7c.af80
                 Cost        0
                 Port        25 (GigabitEthernet1/1)
                 Hello Time   2 sec  Max Age 20 sec  Forward Delay 15 sec
      Bridge ID  Priority    32768  (priority 32768 sys-id-ext 0)
                 Address     1cde.a7f8.4380
                 Hello Time   2 sec  Max Age 20 sec  Forward Delay 15 sec
    Interface           Role Sts Cost      Prio.Nbr Type
    Gi0/1               Desg FWD 20000     128.1    P2p Bound(PVST)
    Gi0/2               Desg FWD 20000     128.2    P2p Edge
    Gi0/3               Desg FWD 200000    128.3    P2p Edge
    Gi0/4               Desg FWD 200000    128.4    P2p
    Gi0/5               Desg FWD 20000     128.5    P2p Edge
    switch1#sh spanning-tree vlan 501
    MST0
      Spanning tree enabled protocol mstp
      Root ID    Priority    24576
                 Address     1c6a.7a7c.af80
                 This bridge is the root
                 Hello Time   2 sec  Max Age 20 sec  Forward Delay 15 sec
      Bridge ID  Priority    24576  (priority 24576 sys-id-ext 0)
                 Address     1c6a.7a7c.af80
                 Hello Time   2 sec  Max Age 20 sec  Forward Delay 15 sec
    Interface           Role Sts Cost      Prio.Nbr Type
    Should I worry about this?

  • Question Keyboard Design on Passport

    Just curious why the drastic keyboard design limitation on the new BB Passport.  I really like the looks of the phone, but am stumpt at why the missing functionality on the hard key - keyboard. 
    I cannot speak for everyone else, but my loyalty to Blackberry (Late 2000's to now) has been because of the hard keyboard functionality. 
    Seems like the engineers could not make up their minds to put hard keys or soft keys. 
    Not for certain I will buy into a less than fully functional keyboard on my blackberry.  Guess I will just keep my old 9930 until it dies. 

    I must admit that it took a few days to get used to the mix of physical and virtual keyboards, coming from a 9810 with full "traditional" BlackBerry keyboard, but now my fingers fly.
    Paul
    Torch 9810; PlayBook 64g; iPad1 64g; iPad2 64g; iPhone6 64g Passport
    Provider Bell (tablets all WiFi)

  • A question about design.

    I have a program I wrote using Visual Basic that I use at my church to print a deposit slip for our weekly offerings.  A pretty simple program.  I enter the check information (giver name, check number, amount) or cash and put that data in a list
    box.  I also total the cash & check amounts to print on a deposit slip.  One aspect of the program is that I store the name and address of anyone who gives to the church and at the end of the year I print a letter giving them the total of their
    offerings throughout the year so they can deduct it on their income tax forms.  The names and address are keep in a simple access database.
    Now, I have added the capability to insert the check in a Magtek MICR check reader and using the account number on the check (which I have stored in the database in the same table that holds the names) I can get the name of the person making the contribution
    along with the check number.  Then I just enter the amount, hit enter and I'm ready for the next check.
    Here is the problem (and it's not a big one): some of our members have two or more checking accounts so I end up with two rows with duplicate information in my database.  My question is should I create another table with the account number and a key
    pointing to the member name?  I know, I've been kinda wordy for such a simple question but I really want the views of the members of this forum.
    Thanks in advance.
    Philip

    Philip,
    Just thinking out loud. How about having seperate tables for the personal info, account and contribution?? Something like below:
    Person
    PersonID, Name, Address and other personal details
    BankAccount
    Account_ID, PersonID, Branch_details etc.
    Donation:
    Donation_ID, Person_ID, Account_ID, Check_Number, Amount, Datetime etc.
    So you can have a track of all names and accounts seperately. Now for the contributions, if a person has given two checks each with different bank account, the same can be captured distinctly with the combination of Account, Check and Donation id. The Person_ID
    can be removed from the last table if we can assume that each account maps to only one person (eliminating the possibility of shared accounts)
    Thanks,
    Jay
    <If the post was helpful mark as 'Helpful' and if the post answered your query, mark as 'Answered'>

  • Other question about Designer 6i Installation

    Hi. I hope somebody help me !
    I Installed Designer 6i (client side) in a Win98 machine. Then I installed Personal Oracle 8i successfully in the same machine. I'm tryin to install Designer's server side. The Tablespaces, roles, repository owner user and other necessary objects are already created. When I tryed to Install the repository through the Repository Administration Utility, I get the following message:
    Warning: Oracle with Enterprise Edition Option is not present. Retry Repository Installation after resinstalling this option.
    What that means and How I do that ?

    Thanks for your answer David. That means there's no way to run Designer 6i and Oracle on the same Win98 PC ?
    <BLOCKQUOTE><font size="1" face="Verdana, Arial, Helvetica">quote:</font><HR>Originally posted by David Brown ([email protected]):
    Juan,
    Personal Oracle is not supported with the Repository.
    Repository 6i Release 1 required 8.1.6 Enterprise Edition of the database, Release 2 and above will run with Enterprise and Standard editions.
    David <HR></BLOCKQUOTE>
    null

  • Question about design pattern - business delegate: repost

    hi guys
    i have got a question to ask about the delegate pattern. usually, we use it to decouple between presentation client and businessservice tiers. for instance, the service tier has an session ejb, and delegate wrapps the ejb. and the web client calls delegate to access service. is the delegate only used by the presentation tier? within the service tier, we can have many ejbs that work together to get tasks done. do we still use delegates in the service tier? what is ur suggestion? thanks

    thanks, but i don't think i follow what u said.
    bascially i was asking if it was still a good idea to use delegates to communicate between ejbs the same way presentation tier calls service tier. i.e. SessionEJBA calls DelegateB to access SessionEJBB. or SessionEJBA calls SessionEJBB directly including the lookup, etc.

  • Question on designing a trivia game with Flash

    Hello everyone! I am new to Flash and I was wondering, if sites like http://www.conquiztador.de/ are made entirely in Flash or is there more to it?
    Thank you for your answers.

    Simple answer: yes. More complicated answer: sort of. The quiz that makes up most of the opening page is done in Flash. There is some sort of back end that keeps track of the users' scores. This was done using something else, javascript, Perl, PHP, or a combination of those and maybe something else. Most of the other sections of that site are not done in Flash.

Maybe you are looking for