Package Names

This is another of my questions related with naming. My problem is that I care so much on naming of packages, classes, methods, variables, etc because I want to make my code as readable as possible.
I read from google about some standards when creating a new package. It states that it must the company domain in reverse. This means "com.companyname.xxxx" or "org.organizationname.xxxx" like "org.eclipse.xxxx" or "com.nokia.xxxx". So far so good...
My problems comes when I have to devide the application classes. I most often use the MVC. so what I do is having
org.organizationname.applicationname.view
org.organizationname.applicationname.control
org.organizationname.applicationname.model
org.organizationname.applicationname.utilHowever I am finding this a little stupid. My problem is I never seen any full application code and so I had to invent these myself. I sometimes change from .control to .business or .services.
My question is how do you usually name the packages to identify between the view, model, control classes??
I also get confused on how to set the package name for an application that will make use of a webservice. Because a webservice is a service, but you could have other things that can be a service. And you can not make your package name too long either!!

This is another of my questions related with naming.
My problem is that I care so much on naming of
f packages, classes, methods, variables, etc because
I want to make my code as readable as possible.
I read from google about some standards when creating
a new package. It states that it must the company
domain in reverse. This means "com.companyname.xxxx"
or "org.organizationname.xxxx" like
"org.eclipse.xxxx" or "com.nokia.xxxx". So far so
good...
"Must" is a very strong word. I believe "recommends" is more correct. We use the reversed URL convention for package names where I work, but it's not mandatory.
My problems comes when I have to devide the
application classes. I most often use the MVC. so
what I do is having
org.organizationname.applicationname.view
org.organizationname.applicationname.control
org.organizationname.applicationname.model
org.organizationname.applicationname.util
However I am finding this a little stupid. What's so stupid? That's the way I see it done.
I think it's only a problem if (1) you can't touch type, (2) you don't have an IDE like IntelliJ that can automatically insert the package name for you when create a class in a package, or (3) you're bothered by a bit of verbosity.
My
problem is I never seen any full application code and
so I had to invent these myself. I sometimes change
from .control to .business or .services.
My question is how do you usually name the packages
to identify between the view, model, control
classes??Yes.
I also get confused on how to set the package name
for an application that will make use of a
webservice. Because a webservice is a service, but
you could have other things that can be a service.Every service is not a web service - two different things. It's a packaging/deployment issue. The fact that you choose to deploy a particular service as a Web service doesn't change its essence.
And you can not make your package name too long
g either!!What do you mean by "too long"?
Do you have a point or a question here?
%

Similar Messages

  • I need to remove "air." from package name. I'm get a Layout xml error when repackaging android app..

    So, i'm doing this on my own app. I made an update for an older app that was build using Native Android. But this time, i used Adobe AIR... The catch is Adobe likes to append a "air." to the front of your package name without asking you. So basically I can't upload my update because it has a new package name is now "air.com.mycompany.myapp" rather than the original "com.mycompany.myapp"
    Basically I'm going through this guide..
    http://helpx.adobe.com/air/kb/opt-out-air-application-analytics.html
    I followed all the steps, made all the adjustments to the androidmanifest.xml like it asks.
    But after going along with the above guide, with no issues when i get to the step that says
    "Run the following command to create the resource file for the updated AndroidManifest.xml:"
    I run this..
        "/Users/brybam/Documents/eclipse/android-sdk-mac_x86/platform-tools/aapt" package -f -M AndroidManifest.xml -F resources.arsc -I "/Users/brybam/Documents/eclipse/android-sdk-mac_x86/platforms/android-8/android.jar" -S ./res
    But I keep getting the same error regarding the xml files in res/layout
        ./res/layout/expandable_chooser_row.xml:1: error: Error parsing XML: not well-formed (invalid token)
        ./res/layout/expandable_multiple_chooser_row.xml:1: error: Error parsing XML: not well-formed (invalid token)
        ./res/layout/main.xml:1: error: Error parsing XML: not well-formed (invalid token)
        ./res/layout/multiple_file_selection_panel.xml:1: error: Error parsing XML: not well-formed (invalid token)
        ./res/layout/ssl_certificate_warning.xml:1: error: Error parsing XML: not well-formed (invalid token)
    The guide doesn't say anything about these xml files, and im not sure what to do with these or how to handle them.
    If i go into the res/layout folder, and just delete these (i know they're necessary. But i just deleted them as a test, to get through the rest of the guide...)
    I was able to get through the rest of the steps in the guide fine, make an apk, and put it on my phone...only to find out the app will crash the moment you try to run it. Probably because i deleted the layout xml files...But i cant get the command i need to run above to accept them!
    So, earlier in the guide they have me use thing thing called the "AXMLPrinter2.jar" to make the AndroidManifest.xml readable so i can edit it.
    I run something like this:
        java -jar "/Users/brybam/Desktop/repackage/AXMLPrinter2.jar" AndroidManifest.xml > AndroidManifest.xml.bk
    This makes a new file "AndroidManifest.xml.bk" and i can edit that.
    So, I was thinking with all of these layout xml files, maybe I could run this "AXMLPrinter2.jar" on them and then edit them. Because right now if you open them they're not human readable, and its hard for me to work on them if they're not...
    I tried this thinking i could do the same thing...
        java -jar "/Users/brybam/Desktop/repackage/AXMLPrinter2.jar" main.xml > main.xml.bk
    Just get a blank file and a console erorr when trying to use the AXMLPrinter2.jar on the layout xml files...
        java.lang.ArrayIndexOutOfBoundsException: 67
                  at android.content.res.StringBlock.getShort(StringBlock.java:231)
                  at android.content.res.StringBlock.getString(StringBlock.java:91)
                  at android.content.res.AXmlResourceParser.getName(AXmlResourceParser.java:140)
                  at test.AXMLPrinter.main(AXMLPrinter.java:56)
    So, I think my whole issue is based around these XML files not being converted to human readable before i try and re-package....
    EDIT:::
    Ok, so I found a site that talks about the error I'm getting but it's in chinese, and even after translating the page...I'm still not well versed with terminal and this stuff to get it.
    It reads:
    "Error.
    Final conclusion:
    In minSdkVersion <= 7, AXMLPrinter2.jar can normally decompile xml file
    Greater than 7 can not be normal decompile xml file (AndroidManifest.xml except)
    Give way to share a batch decompile xml file:
    First, create a *. Txt file
    Stresses inside the content authoring
    for / r layout%% a in (*. xml) do @ java-jar AXMLPrinter2.jar "%% a" >> "%% a". txt
    Then this txt file extension into bat form, and this BAT the file and AXMLPrinter2.jar on the same directory will be decompiled xml into the layout directory
    Decompilation results can be generated by executing the bat file multiple xml files."
    - http://hi.baidu.com/ghcghc/item/ecbaa1ce997cb225a0b50ac2
    Maybe someone with more know-how could explain what they're explaining? I get that he's saying the issue im seeing appears when you're using minSdK <=7 but I need to use minSdk 8. Does anyone understand this work around? And how I might go about it on a Mac with terminal?
    I wish adobe would make it easy to remove the "air." from the package name. If they want to convert old Native devs to AIR devs...the transition needs to be seamless. But now I'm about to have to go back to Native because I can't update an app I already have out on the market with an air app.

    Hello~
         I also tried to remove "air." package name in air application. And i encounter the same problem.
         I do not find any solution to decode the xml inside res folder by AXMLPrinter2.jar. And those xml inside is compressed which is unreadable.
         However, what you can do is copying the structure of res folder. And go to your air sdk file path -  adobeair-sdk-folder/lib/android/lib/resources/
         Replace those file exists in your res folder. And copy "values" folder to your res folder.
         Hope this solve your problem~

  • Class name and package name clashing

    When i have a class and a package with the same name, I cannot access classes in the package. For example I have 3 classes and 1 package as below
    - Test.java
    - PackageName.java
    + PackageName // this is a directory
    - MyClass.java
    Below are the codes of .java files
    Test.java
    =======
    public class Test { PackageName.MyClass a = new PackageName.MyClass ();}
    PackageName.java
    ===============
    public class PackageName{ }
    MyClass.java
    ==========
    package PackageName; public class MyClass { }
    I can compile PackageName.java and MyClass.java but not Test.java. It says
    cannot resolve symbol
    symbol : class MyClass
    location: class PackageName
    PackageName.MyClass a = new PackageName.MyClass ();
    But if I remove the PackageName.java, I can compile Test.java perfectly. I think when I use PackageName.MyClass, java thinks that I try to access an inner class MyClass of PackageName class, and that does not exists. Is there any way to solve this ambiguation, other than making the package name and class name different? Thank you very much.

    This works fine: just add an import to Test.java.
    import PackageName.MyClass;
    public class Test
        public static void main(String [] args)
            MyClass a = new MyClass();
    public class PackageName {}
    package PackageName;
    public class MyClass {}It's a pretty wacky, useless example, but it works.
    Plus I thought inner classes would have a dollar sign in their .class file names. When I compile this:
    public class OuterClass
        public static void main(String [] args)
            OuterClass outer = new OuterClass();
            System.out.println(outer);
        public String toString() { return "I'm an OuterClass"; }
        class InnerClass
            public String toString() { return "I'm an InnerClass"; }
    }I see two .class files: OuterClass.class and OuterClass$InnerClass.class
    Why make up examples like this? It's hard enough writing code, and it's easy to disambiguate for the compiler.

  • How to change the package name of Managed Bean class

    Hi: Gurus, when ever I create a new JSP page the Creator creates a code behind file with a package name untitled. Is there any way to change this package name? Can't the Creator gives us an option before genereating manged bean page to choose a package name? And then create the Java source directory structure on the basis of the pakcage name?
    Regards,
    Rashid.

    In the Project Navigator (default location is middle right), go to Java Sources, and you can rename the package ("untitled") to something else by right-clicking it or by left-clicking (just like Windows Explorer).
    I agree, though, that giving the developer an option during creation of the JSP page would be nice.

  • The package name The Gallbladder-4.itmsp contains an invalid character(s).  The valid characters are: A-Z, a-z, 0-9, dash, period, underscore, but the name cannot start with a dash, period, or underscore

    I have an iBook on itunes and I am trying to upload a new version of the book. I am following the workflow through iBooks Author and when I fell out all of the infromation for the package on iTunes producer i then hit the deliver button and I get the following error message:
    The package name The Gallbladder-4.itmsp contains an invalid character(s).  The valid characters are: A-Z, a-z, 0-9, dash, period, underscore, but the name cannot start with a dash, period, or underscore.
    As far as I can tell the file that is being referenced does not meet the criteria axpressed in the erro message and in fact that file has been created by iBooks Author so one would think there shouldnt be an error.
    I also get the following to error messages:
    Apple's web service operation was not successful
            Unable to authenticate the package: The Gallbladder-4.itmsp
    Would ove any help.
    Thanks,
    Jeff

    Thank you so much for your help.
    For anyone that would like to check out this book it can be downloaded at:
    https://itunes.apple.com/us/book/the-gallbladder/id598317335?ls=1
    Please check out our free medical education blog by Jeffrey Eakin using iBooks Author at:
    http://free-medical-education-ibooks-author.blogspot.com

  • Difficult to get good package names with ojspc in automated build

    If I understand the documentation for "ojspc" correctly, there is an aspect of its functionality that makes it difficult to have a convenient automated build which can also get good package names for the generated Java source files.
    If you don't specify the "-packageName" option, ojspc will build a package name relative to the current directory, including sub-directories. However, specifying "-packageName" will ONLY use that package, and will not create sub-packages associated with sub-directories.
    If you don't use the "-packageName" option, then you have to run the build from the root directory of your JSP files. When you're running an automated build with ANT, it's not convenient to do this.
    The likely result of this is that I would have to make sure that all of my JSP files are named differently, even if they're in different directories, and use the "-packageName" option to specify a particular package name for all of the generated source files.

    After more careful reading, I realized that using the "-appRoot" option (without using "-packageName") makes it possible for an ANT build to generate good package names (with directories).
    The following note, however, in the ojspc documentation is kind of odd:
    "It is advisable that you run ojspc once for each directory of your JSP application, so files in different directories can be given different package names, as appropriate."
    I assume this is referring to using the "-packageName" option. If you don't need to use "-packageName", especially if you have multiple directories of JSP pages, it is much easier to just let ojspc pick the package names.

  • Not allowed to import classes without package names?

    Hi,
    I have a few questions on Packages and importing?
    1. Is the following true that it is illegal to import classes in the same package as the current class, will this cause a comilation error? If this is the case where in the Java Language specification is this actually written as I could not find it?
    2. This has probably been answered by question 1 but if I have 2 classes in the same package and if I import 1 of the classes into the other class, is it illegal to import it by just using the class name and not the package name as well, ie
    if the package name is ie.tcd
    and the 2 class names are exp1.class and exp2.class, can I do this in class 2
    package ie.tcd;
    import exp1;
    public class exp2 {
    3. Is it illegal to import classes that are not explicitly part of any package or must a class be part of a package to be imported. I read somewhere that while this was always illegal it is only after jdk 1.4.2 that this is being enforced? If this is the case where in the Java Language specification is this actually written as I could not find it either?
    Thanks very much for any help,
    John

    Was just also wondering, 1 other thing, I am looking
    at someone elses code they have 2 classes (Class A
    and Class B) in the same package (pkg). The person
    imports class A into B:
    package pkg;
    import A;
    public class B {
    Is this legal code (or was it ever)?Not if A is really in pkg.A. If there is an A in the unnamed package it was legal, or at least it was understood by the compiler, and now it isn't (to both).
    Can you import or is there a point in importing a class in the same
    package?Only by naming the package in the import statement. If the current and the import statement are in the same package the import is redundant.
    If there is a point would you import just be
    using the class name (this would be illegal after jdk
    1.4) or should you use the whole package name even
    though it is in the package anyways?As I understand it you must always use the whole package name in imports.

  • Package name in Solaris 10

    Hi,
    I try to uninstall the following path:
    /usr/spool/lp/model/ppd/system/foomatic
    for all the printer model files.
    Is there a Solaris 10 Package name associate with these files that I can use pkgrm to do?
    Thanks!

    You can get the associated package name by running:
    grep lp\/model\/ppd\/system\/foomatic /var/sadm/install/contents | awk '{ print $10 }' | sort -u

  • How to get the package name of a procedure used in a process flow activity

    Hi all. I'm on OWB 11.2.0.2.0.
    When I used a packaged procedure or function in a mapping operator, I can find out the package.program_unit name by getting the operator's FUNCTION_NAME property. For example,
    OMBRETRIEVE MAPPING '$mapName' OPERATOR '$operName' GET PROPERTIES (FUNCTION_NAME)
    But when the same is used in a process flow activity, I can't find a property name that will give me the same information. I can get the BOUND_NAME, it does not tell me the package name. It must be stored in the activity properties because when you pull up the Synchronize dialog for the activity, it knows the package name.
    Is there a way to get this via an OMBRETRIEVE?
    Thanks.

    ANA, this is exactly what I needed. Thank you so much. I saw REFs also in the OMBRETRIEVE MAPPING/OPERATOR syntax, but went cross-eyed trying to figure out if I could use the same there. The closest I found was GET BOUND_OBJECT.
    Thanks again!

  • 2.1 RC1 - Search Source Code results - Go To package name doesn't work

    Hi.
    When I perform a search through Reports -> Data Dictionary -> PLSQL -> Search Source Code and I right-click -> Go To ... on a row of the results, nothing happens.
    Regards.
    Alessandro
    Edited by: archimede on Dec 2, 2009 12:29 PM

    Sorry Vadim, but the procedure to reproduce the bug is different:
    1) Open the Reports tab
    2) Expand Data Dictionary node
    3) Expand PLSQL node
    4) Click on Search Source Code
    5) Select a Connection
    6) Click on Text Search, enter a string to search and click Apply
    7) On the results page, right-click any line and select Go To <package name>
    8) The package opens on line 1, not the line shown on step 7
    While we're at it, do you think it would be possible to make the above process more user-friendly? Like, for example, right-clicking on a Connection and have the Search Source Code option there (that would take me directly to step 6)?
    Regards.
    Alessandro

  • Change package name of a form

    Hi,
    I want to change the package name of a Form in se71 from $TMP to a company package name. I would like to know the step by step process and direct answer please!
    Points will be rewarded!
    Thanks!

    Hi there,
    I believe the only solution for your issue is to open the form in the change mode,
    then click on the File--> Save As and then give some name and assign the package,,
    then you can always delete the previous form save in $tmp.
    Let me know if you need further help.
    Thanks-

  • Changing Package Name of an AIR apk

    Hi. I have created an AIR app that is currently in the market. To update the app, obviously I must keep the same package name. My first version's were packaged using Eclipse with the ADT plugin.
    Now to use AIR 3.0 Native Extensions (ANE) which were not available when I first developed the app, I currently must create my APK using AIR's command line tools. Unfortunately, these command line tools force you to have a package name that starts with the word "air". For example, I need the package name "com.example". AIR creates the package name as "air.com.example".
    So now, I cannot update my app in the market since the package name has changed. Adobe has this horrific article to help you rename and remove the "air" in the package. I'm not a great programmer so this has really stumped me.
    http://kb2.adobe.com/cps/875/cpsid_87562.html
    Apparently this info is out of date or incorrect in a few areas.
    I have completely stumbled at step 12 which uses apkbuilder:
    apkbuilder final.apk -u -z resources.arsc -f classes.dex
    I am getting this error message:
    THIS TOOL IS DEPRECATED. See --help for more information.
    java.io.FileNotFoundException: resources.arsc does not exist
    I have used step 10 to create the new resources.arsc file. It clearly DOES exist and in the correct location. I tried using apkbuilder with other resources.arsc files taken from other projects. I still get the same error message.
    Maybe there is another way to do this using another tool like like apkTool. http://code.google.com/p/android-apktool/
    I tried this but then couldn't get jarsigner to sign the apk properly.
    Is there a chance in hell of this working? There doesn't seem to be much about this topic on the internet. If anyone is interested in this, I have a zip file with a sample AIR apk, windows bat files for all the command line work, and all the needed utilities so they don't need to be downloaded. To get started you just need to change my path.bat to fit your system. And you need notepad++ (or an equivalent) to batch automate renaming the package name across several files.
    http://bradwallacedesign.com/dktimer/renameApkProject.zip
    Thanks so much!

    If the DisplayObject is on the timeline then its name cannot
    be modified, but the name property of dynamically created
    DisplayObjects can be changed. (DisplayObject.name:String
    read/write).

  • Function not found when package name exists with same name as schema name

    Hi all, any help would be appreciated :)
    I found an issue with pl/sql resolving a functions location when the db has a package name with the same as the db schema name.
    My example:
    -- arbitrary test function, not in any package
    create or replace FUNCTION testFunc
         inTest     IN VARCHAR2
    RETURN VARCHAR2
    AS
    BEGIN
    RETURN 'a';
    END;
    -- There is a package called "FM" with functions that are not referenced or used in this example and the db schema is "FM".
    -- The following PL/SQL fails with the message: "ORA-00904: "FM"."TESTFUNC": invalid identifier"
    select cursor (select testFunc('a') from dual) from dual;
    -- The following PL/SQL works:
    select * from (select testFunc('a') from dual);
    As mentioned the function testFunc is NOT in the FM package. This issue does not happen when I remove the FM package. So it seems like there is an issue with cursors calling functions when there exists any package with the same name as the db schema.
    Can anyone tell me why this happens and also what I can add to force the function that is not in any package to be referenced (without Oracle trying to look in the FM package)?
    DB: Oracle 11.2.0.2
    thanks!
    Paul

    Hi Paul,
    In general I would not advice to have schema and objects with the same name.
    Here is what documentation is saying here: How Name Resolution Differs in PL/SQL and SQL
    PL/SQL uses the same name-resolution rules as SQL when the PL/SQL compiler processes a SQL statement, such as a DML statement. For example, for a name such as HR.JOBS, SQL matches objects in the HR schema first, then packages, types, tables, and views in the current schema.
    PL/SQL uses a different order to resolve names in PL/SQL statements such as assignments and subprogram calls. In the case of a name HR.JOBS, PL/SQL searches first for packages, types, tables, and views named HR in the current schema, then for objects in the HR schema.As you can see above when using PL/SQL for your case Oracle searches first for packages, types, tables, and views named FM in the current schema, then for objects in the FM schema.
    And because a package FM is found it is raising an error due to the fact that the procedure could not be found in that package.
    I hope this clarify.
    Regards.
    Al

  • How to find package name of transactioncode

    hai friends,
            how i can find the package name for a given transaction code .
    i think by using se93
    Moderator message: please search for available information.
    Edited by: Thomas Zloch on Jul 8, 2011 9:52 AM

    Not sure, if this is what you're looking for
    SQL> create or replace procedure p0 as
      2  begin
      3    dbms_output.put_line(dbms_utility.format_call_stack);
      4  end;
      5  /
    Procedure created.
    SQL> create or replace procedure p1 as
      2  begin
      3    p0;
      4  end;
      5  /
    Procedure created.
    SQL> create or replace procedure p2 as
      2  begin
      3    p1;
      4  end;
      5  /
    Procedure created.
    SQL> set serveroutput on
    SQL> begin
      2    p2;
      3  end;
      4  /
    ----- PL/SQL Call Stack -----
      object      line  object
      handle    number  name
    3a7f2d618         3  procedure INV_ADM.P0
    39abfeef0         3  procedure INV_ADM.P1
    39c5ae7a0         3  procedure INV_ADM.P2
    3a0f3a538         2  anonymous block
    PL/SQL procedure successfully completed.
    SQL>

  • How to call a stored procedure using its package name in Oracle

    hi
    we're doing a JDBC scenario where we call a stored procedure(a.prc) using its package name(b)The stored procedure has In /Out/IN-OUT parameter.
    i have got 2 queries:
    1- How to call the stored procedure using it's package.
    2- How to capture the In/Out parameter in the response.

    hi Prateek
    thanks for the reply.
    However when i tried mapping it to Package.procedure, communication channel throws the error saying that Package.proceudre needs to be declared.
    As i said , the procedure has IN-OUT parameter too.In oracle we need to write a block if we want to read the IN-OUT parameter.
    How to get the IN-OUT parameter in XI?

  • In the header file generated by javah, the package name is not in the funct

    and in the header file generated by javah, the package name is not in the function declaration:
    /* DO NOT EDIT THIS FILE - it is machine generated */
    #include <jni.h>
    /* Header for class VocalJNITest */
    #ifndef IncludedVocalJNITest
    #define IncludedVocalJNITest
    #ifdef __cplusplus
    extern "C" {
    #endif
    * Class: VocalJNITest
    * Method: JNI_1myJNI
    * Signature: ()V
    JNIEXPORT void JNICALL Java_VocalJNITest_JNI_11myJNI (***please not there is no package name in it****)
    (JNIEnv *, jclass);
    #ifdef __cplusplus
    #endif
    #endif
    In the VocalJNITest.java file, I put package com.jni.test in it, why dose it not appear in the VocalJNITest.h file.

    it works,
    thanks alot, but java really confuses me, for example, if i run the app, i need to type the complete name java com/...../jnitest, in which the "/" is used instead of
    ". " like com.vocal.jnitest as the package name in the source file.
    but when using javah, i need to use ". " instead of "/";
    i tried com/vocal/jnitest, but failed so i post the question here.

Maybe you are looking for