Packages and packages

Hi
I was rereading Martin's principles of package architecture and was wondering how the concept of package in this context relates to the concept of a Java package
after thinking a bit, I got the feeling these two concepts have nothing to do with each other
I feel that Java packages deal with namespace and access control, while OO packages (the components of your program's binaries) would be, in the Java world, jar files containing classes from different packages (and not especially all classes from these (Java) packages), and constructed as much as possible in order to follow these supposedly good OO principles
Am I right ? partially ? totally ? totally not ? I need some insight on this

Kind of. But what would stop me to define the
namespace on a per-component base? I used structures
like com.mycompany.myapp.database (data tier),
com.mycompany.myapp.web (presentation tier) and the
likes. You could put classes (or packages) belonging
to a certain subsystem into a package dedicated to it.I did it for a long time too, traditionaly with webapps :
be.mycompany.myapp
dataaccess
business
web
and that worked fine... but that's not my concern
actually, what concerns me is the business package itself... I'm writing a very simple peer2peer file sharing tool for both fun & education, and the packaging becomes trickier, since the app is naturally distributed :
* file sharing client package
* user manager client package
* server package (handles login requests & user management requests)
thing is, I reuse many classes among these three "kinds of endpoint", which makes me think about properly dividing my app into small reusable, well-organised components... when java packages come into play, things are getting less clear as of how I should do...
how do you people do when it comes to structuring (packages AND deliverables of) your business layer ?

Similar Messages

  • Variable declaration in Package and package body

    Hi
    Kindly reply the difference in declaring a cursor inside a package vs package body
    eg:
    create or replace package shapak is
    cursor shacur is select * from sha;
    function shafun return number;
    end;
    i can declare the above cursor inside the package body withoout declaring in package specification. but what is the difference?
    reply appreciated
    thanks
    shajan

    In general..Items declared in the package spec are visible outside the package..so you can say public.where as items declared in the body are restricted to use within the package..such items are called private.

  • Why a semi-colon is not enough when creating packages and package bodies?

    Hi,
    I'm struggling with a quite simple problem - when creating a package header and body in the same script, it does not work as expected. See for example this very simple package:
    CREATE OR REPLACE PACKAGE mypackage AS
    PROCEDURE test_proc(id INTEGER);
    END mypackage;
    CREATE OR REPLACE PACKAGE BODY mypackage AS
    PROCEDURE test_proc(id INTEGER) IS
    BEGIN
    NULL;
    END test_proc;
    END mypackage;
    When executed from JDeveloper (or sqlplus), the package is created but with a "PLS-00103: Encountered the symbol CREATE" error. It seems Oracle does not recognize the script contains header and body, and uses the whole script as a header (which is obviously wrong).
    If modified so that there are "/" everything works fine:
    CREATE OR REPLACE PACKAGE mypackage AS
    PROCEDURE test_proc(id INTEGER);
    END mypackage;
    CREATE OR REPLACE PACKAGE BODY mypackage AS
    PROCEDURE test_proc(id INTEGER) IS
    BEGIN
    NULL;
    END test_proc;
    END mypackage;
    Why is this necessary? Why Oracle does not recognize that "END mypackage;" actually ends package header definition, and combines it with the body definition into an invalid block? I've thought semicolon is a valid separator, so why is the "/" necessary?
    It does not work even when I try to run the statements separately (from the same worksheet in Jdeveloper) - first select the header block, hit F9 (execute statement), then repeated the same for body. In this case both header and body are created, but are invalid because the last semicolon is removed from them (so it's not possible to compile them).

    For that to work, the SQL engine would have to understand PL/SQL syntax. Only the PL/SQL compiler knows when all the END statements have matched up with their corresponding declarations, and it doesn't do CREATE statements. I guess it could detect that the compilation unit it started has finished and pass any text left over back up to SQL to have another shot at. I'm not sure that's reasonable. There is no other example in SQL where one CREATE statement can turn into two - e.g. you can't send a block of CREATE INDEX statements together and expect the database to parse them out into separate commands.
    Edited by: William Robertson on Jun 6, 2009 6:49 PM
    Edited by: William Robertson on Jun 6, 2009 6:51 PM
    Added example about indexes.

  • UNIX: Spool out database package and package body to a file [SOLVED]

    Hello,
    Does anyone know what I need to type into the unix console in order to spool out a database package spec and body of my choosing to a file? I've been told that I've got to do something like:
    set trim spool on
    With the idea that the trim will wrap the lines in the file so that words aren't half cut off. But the unix console tells me those commands don't exist?
    Thanks,
    - A Developer Scorned
    Message was edited by:
    A Developer Scorned

    Thank you very much gintsp. I did not realise they were sqlplus commands.
    In order to spool out a datababase package spec and its accompanying body through sqlplus in unix, I found the following post helpful too: how to generate text file using spool command
    Simply load up sqlplus and enter in the commands (set verify off, set feedback off etc), and specify a file to spool out to. In order to spool out the text of a database package, simply use:
    select text from dba_source where name = <your package name here>
    That way the spec will be spooled out followed by the body.
    Thanks,
    - A Developer Scorned.

  • What is the difference between the function declared in the package and pac

    What is the difference between defining a function in the package and package body ?
    Edited by: user10641405 on Nov 19, 2009 1:29 PM

    If you describe a package, you will only see the functions declared in the spec.
    If you only declare them in the body then they are not available to other packages (they are private to the package, not public)

  • How to make a package and import it later

    Hi folks,
    this is a very basic question but it is not working to me so i will appreciate your comments.
    I had programmed many classes that are going to be used in many projects so they must be part of a library. Tell me whether or not this procedure is correct ?
    Compile those classes into .class files. Create a package with the jar application putting the .class files into a single file called my_utils ( .jar or .zip ?). Import the package from other projects using the import directive and storing the my_utils file in the project's library directory. Is this correct ?
    Many thanks in advance
    Marla.

    If you want to create a package and then put the package into a jar file, first compile into .class files (in appropriate package directories), then jar all of the .class files.
    Here's a link for a tutorial on packages. http://java.sun.com/docs/books/tutorial/java/interpack/packages.html
    Here's a link for a jar file tutorial. http://java.sun.com/docs/books/tutorial/jar/index.html
    You do not have put the .class files into a jar. Java packages are used for organizing classes, managing class name space, and controlling access to classes. Java jar files are a way to put multiple classes into a single file while compressing the content. Jar files can contain multiple packages and packages do not have to be inside of jar files.

  • How to copy procedures and packages from one server to another?

    Hi,
    I have 439 packages and 178 procedures located in one server called MAXWELL.
    I need to copy these objects to another server called TITAN.
    The schema names is SPCBR in both servers.
    So both servers have an instance running with this schema SPCBR.
    SPCBR in TITAN server has their tables with table data which was generated by an export/import process from MAXWELL server.
    However, procedures and packages were not copied by the export/import because I used the clause 'tables'.
    Now, what can I do in order to equalize procedures and packages in both databases? I can't risk in damaging or duplicating data in my database located in TITAN server, ok?
    Thanks,

    Another simple alternative, according to AskTom (http://asktom.oracle.com/pls/ask/f?p=4950:8:::::F4950_P8_DISPLAYID:454220160386)
    ---------------- getcode.sql ----------------------------
    set feedback off
    set heading off
    set termout off
    set linesize 1000
    set trimspool on
    set verify off
    spool &1..sql
    prompt set define off
    select decode( type||'-'||to_char(line,'fm99999'),
    'PACKAGE BODY-1', '/'||chr(10),
    null) ||
    decode(line,1,'create or replace ', '' ) ||
    text text
    from user_source
    where name = upper('&&1')
    order by type, line;
    prompt /
    prompt set define on
    spool off
    set feedback on
    set heading on
    set termout on
    set linesize 100
    ------------------- eof --------------------------------
    it extracts one procedure, function or package to a file. Thats it. If you
    wanted to get all of the procedures in a schema extracted to the current working
    directory, you would run a script:
    --------------- getallcode ---------------------------
    set termout off
    set heading off
    set feedback off
    set linesize 50
    spool xtmpx.sql
    select '@getcode ' || object_name
    from user_objects
    where object_type in ( 'PROCEDURE', 'FUNCTION', 'PACKAGE' )
    spool off
    spool getallcode_INSTALL.sql
    select '@' || object_name
    from user_objects
    where object_type in ( 'PROCEDURE', 'FUNCTION', 'PACKAGE' )
    spool off
    set heading on
    set feedback on
    set linesize 130
    set termout on
    @xtmpx.sql
    ---------------- eof ---------------------------------
    You can see how to filter on that one by adding to the where clause if you want.
    Just run @getallcode_INSTALL to run all of the scripts...

  • I just upgraded my iMac to Lion, and a few seconds ago, I upgraded the iWork package and now I'm having some problems with the new version of Pages (4.1) When I try to change something in a document, a message says "the program is not responding"

    I just upgraded my iMac to Lion, and a few seconds ago, I upgraded the iWork package and now I'm having some problems with the new version of Pages (4.1) When I try to change something in a document, a message says "the program is not responding", so I have to force it to close. By the way, the SAVE botton stays the same even I change erverything in my document. Please, a have a work to finish, **** me. What I can do abou it?

    I just upgraded my iMac to Lion, and a few seconds ago, I upgraded the iWork package and now I'm having some problems with the new version of Pages (4.1) When I try to change something in a document, a message says "the program is not responding", so I have to force it to close. By the way, the SAVE botton stays the same even I change erverything in my document. Please, a have a work to finish, **** me. What I can do abou it?

  • Best report to check application and package deployment compliancy?

    I am looking for the best report to check application and package deployment compliancy.
    Preferably targeting a collection.
    tconners

    I'm recommending this one:
    Software Distribution - Application Monitoring folder -
    All application deployments (advanced)
    It allows you to select Collections and applications
    Kent Agerlund | My blogs: blog.coretech.dk/kea and
    SCUG.dk/ | Twitter:
    @Agerlund | Linkedin: Kent Agerlund |
    Mastering ConfigMgr 2012 The Fundamentals

  • Class name and package names

    I read a passage from some Java Book (sorry don't have the reference handy) that
    "It is illegal for a package and a class to have the same name, so there can be no ambiguity."
    Yet I have created a class named pkgclass within a package with the very same name.
    i.e.
    package pkgclass;
    public class pkgclass {
    This compiles just fine. Have I misinterpreted the statement from the book? What is it trying to say?
    Thanks in advance.

    Here's a quote from the Java language spec:
    "The hierarchical naming structure for packages is intended to be convenient for organizing related packages in a conventional manner, but has no significance in itself other than the prohibition against a package having a subpackage with the same simple name as a top level type (�7.6) declared in that package."
    So your book was not quite correct, or maybe you just misremembered it (clearly you are typing from memory there). It isn't illegal for a package to have the same name as a class, as in your example. But it is illegal for a package to contain a subpackage and a class with the same name.

  • Resolving name and package of a class (kind of reflection stuff)?

    Hi
    I have a class in which I would like to resolve it's own class name and it's package (like "MyCalss" and "com.MyCompany").
    I had a look at java.lang.reflection but couldn't find a way to do this. Does anyone know, how this could be done?
    Thanks a lot for your help.
    josh

    The Class.getName will return the fully qualified name of the class which can the be parsed into package and class.
    String name = obj.getClass().getName();

  • I'm trying to download office 365 small business package, and every time I try the website it says there is a runtime service error in the '/' application. Is this my mac or is it the website, and how can I fix it?

    I'm trying to download office 365 small business package, and every time I try the website it says there is a runtime service error in the '/' application. Is this my mac or is it the website, and how can I fix it?

    If a phone is sold from one friend to another and wants to use it on a different carrier the friend can contact the carrier it was sold by to request it unlocked.  I know AT&T, Verizon, and Sprint will give you the steps to unlock it as long as the original contract it was bought under has been completed.  eBay/Craigslist is really not the best place to try to get "unlocked phones" from, if it turns out the phone isn't unlocked then I'm really sorry you got stuck with that one and as stevejobsfan said above I would report them immediately and see if you can recover your money.  I sell phones for a living and this happens a lot

  • How to create package and import from jar file?

    Hi all,
    I am writing a software and I am not sure how to create a package for the classes.
    Say I have two classes in the same directory as follows:
    testA.java
    ==========
    package AB;
    public class testA
    public static void main(String[] args){
         testB myB = new testB();
         System.out.println("A test");
    testB.java
    ===========
    package AB;
    public class testB
    public testB(){
         System.out.println("B constructor");
    both file compile without the package heading;
    both file compile using: javac -classpath .\ *.java
    Question 1:
    I cannot run testA by: java -classpath .\ testA
    I think it is a syntax error. What is the correct one?
    If I run testA by: java testA
    The only output I get is: A test
    But I am expecting: B constructor /n A test
    What went wrong?
    Question 2:
    I need to use APIs of another software. I have downloaded a .jar file (xxx.jar) with all the classes in it. And I have put "import xxx.*;" in my source file. But the compiler complains about the importing. What is the right way to copmile it?
    I have read a couple of tutorials but they don't answer my question.
    (I am using windows2000 and don't have the classpath variable.)
    Hope some one can help.
    Thanks a lot

    Try moving testA out of the package and importing 'AB.*;'
    If you have:
    ./testA.class
    ./AB/testb.class
    Then to execute testA from ./ type: java -cp . testA

  • Which Privilege needed to create a new Package and Stored procedure usage(in HANA studio)

    Hello Friends,
                           In my company I have access to SYSTEM user(i.e. having all required permissions) ,I wish to create new " USER(s) " for trainees thus which "System privilege" or other privileges is/are needed for the following requirements -
    1>To allow the "new user" to create new Packages(and the columnar views inside it and be able to execute,edit them) 
    2>Create Procedures inside their schema and execute using  "call " command
    I have given the following privileges as suggested by an ebook (SAP certified author).
    The SELECT privilege on the _SYS_BI schema
    The SELECT privilege on the _SYS_REPO schema
    The EXECUTE privilege on the REPOSITORY_REST procedure
    According to my knowledge "create schema" should be given for new schema creation.For my other requirements which all privileges are needed.
    Thanx.

    In addition to Krishna if you don't want to expose all the package to the trainee, then create a new role keeping everything same as default MODELING role (open it and have a look) but in "PACKAGE PRIVILEGES" add only those package that you want to expose to the end users.
    Regards
    Kumar

  • Creating Packages and Namespace for Webdynpro Java applications in NWDS

    Hi Experts,
    I am working on a stand alone application and using NWDS for the same. This application consist of some Webdynpro Java apps, Dictionary perspective DC's and BPM applications.
    I need to create a package and name space for all the applications. I have read some documents on creating SC in SLD and using it in NWDI. But since I am working on NWDS i am not able to see the SC.
    May be I am not following a correct procedure. Can some one provide a basic document or can tell me steps in short that i need to follow, for Name space and package creation and how to use them in NWDS.
    I am working on CE7.1 ehp1.
    Regards
    Pranav

    HI,
    This blog expalins how to Setup and configure NWDI System land scape:
    /people/bhavana.gupta/blog/2007/01/23/installation-and-configuration-of-netweaver-development-infrastructure-was-64
    NWDI Post installation:
    https://www.sdn.sap.com/irj/sdn/go/portal/prtroot/docs/library/uuid/419b479b-0801-0010-f8a1-c26208b4b209
    http://help.sap.com/saphelp_nw70/helpdata/en/44/60dc1943c2311ce10000000a155369/frameset.htm
    Complete NWDI Resources:
    NWDI Resources [original link is broken]
    Thanks
    SrinivaS

Maybe you are looking for

  • HP LaserJet 2100TN Errors in Leopard

    Greetings! First off, I must say that after searching the forums for the past hour, I've been impressed with this community, particularly Andrew (the HP developer). Unfortunately, I didn't find an answer, thus this posting! I upgraded to Leopard abou

  • How do I convert the PDF to Word doc?  It is not working for me

    Just downloaded the conversation and I am not successful - need to convert PDF to WOrd doc -  step-by-step instructions please

  • Monitor for mini?

    I have to replace an old 20" iMac. If I get a new mini what inexpensive monitor would look at least as good as the iMac display it would replace? This new computer would not be used for any graphic work, just online things: internet browsing, email,

  • Not getting response in soap ui after cache refresh

    Hi Experts,       I have a scenario SOAP- PI-RFC Synchronous scenario. when we are trying to send message in  SOAP UI nothing is coming to PI and its showing blank in soap UI . Before doing cache refresh all interfaces were working fine in QA but aft

  • How to create agreement between supplier and distributor?

    Hi.. How to create agreement between supplier and distributor? thanks & Regards Harish