Where to put other source code

133 views
Skip to first unread message

Dan Vega

unread,
Sep 24, 2010, 9:08:27 AM9/24/10
to framework-one
This is one of those things thats not a huge issue but I always like
to see what other people are doing.

I have a FW/1 project

+project
+assets
+config
+controllers
+layouts
+models
+services
+views
+tags
-Application.cfc
-index.cfm

I have a ton of other code that needs to go somewhere. For instance on
this project (its a one off) I need to include

-coldspring
-org.cfcommons.*
-fw1.org.corfield.framework.cfc
-cfformprotect
-Hyrule

I could move fw1 and commons both into an org folder but I guess from
a top level where should this code go. I have used lib and src in the
past but again I would like to see what you guys do.

+lib
+src

David Long

unread,
Sep 24, 2010, 9:47:39 AM9/24/10
to framework-one
I generally throw other code into an org folder. Within there it
depends on how much other code I am using. On a recent project I have
worked with a ton of CFC wrappers that other people wrote to interact
with Payment Gateway API's Shipping API's and so I gave each author a
folder and within there named the CFC's so that I would be able to
know what project they are. For smaller projects I will generally
just throw the code into org/project-title. For example Transfer-ORM
would go in org/transfer and FW1 would go into org/fw1.

Dan Vega

unread,
Sep 24, 2010, 9:54:38 AM9/24/10
to framew...@googlegroups.com
well org is the package name and not all open source projects package names start with org.

com is actually used a little bit more and for that reason I don't want random com and org folders roaming my project root

enigment

unread,
Sep 24, 2010, 10:12:31 AM9/24/10
to framew...@googlegroups.com
I use lib for things that are external to the project, at various
levels. There are lib dirs in js and css for example, and one at the
top level for external cf/java/whatever.

Dave

Sean Corfield

unread,
Sep 24, 2010, 11:25:09 PM9/24/10
to framew...@googlegroups.com
On Fri, Sep 24, 2010 at 6:08 AM, Dan Vega <dan...@gmail.com> wrote:
> This is one of those things thats not a huge issue but I always like
> to see what other people are doing.
>
> I have a FW/1 project
>
> +project
>  +assets
>  +config
>  +controllers
>  +layouts
>  +models
>  +services
>  +views
>  +tags
>  -Application.cfc
>  -index.cfm
>
> I have a ton of other code that needs to go somewhere. For instance on
> this project (its a one off) I need to include

I generally have everything outside my webroot that doesn't need to be
there and then I have a structure like this:

/thirdparty -- this is where all my libraries and frameworks live
/myapp -- this is where my application views, layouts, controllers,
services and model live (normally named for the application itself)
/controllers -- my FW/1 controllers
/layouts -- FW/1 layouts for the app
/model -- my application model
/beans -- transient stuff
/services -- application services
/views -- FW/1 views for each section / item
/www -- this is where web-accessible content lives:
/assets/ -- my assets:
/css - my CSS
/img -- my images
/js -- my JS code
/thirdparty -- this is where JS / CSS / image libraries live that
I didn't write
Application.cfc -- myapp's entry point
index.cfm -- empty

I create a /myapp mapping to the top-level /myapp folder and set
variables.framework.base = '/myapp' (which automatically sets cfcbase
as well). And of course appropriate mappings for all the frameworks
(the mapping for FW/1 has to be in the admin because Application.cfc
extends it but the rest could be in the Application.cfc file itself).

The reason for separating out third-party stuff so clearly is
licensing and legal audits. It's a habit I developed at Adobe. It
makes sure that *no* third-party licensed code ever ends up in the
same directories as your own (proprietary) code. It makes legal audits
of software licensing much, much, much easier!
--
Sean A Corfield -- (904) 302-SEAN
Railo Technologies, Inc. -- http://getrailo.com/
An Architect's View -- http://corfield.org/

"If you're not annoying somebody, you're not really alive."
-- Margaret Atwood

Scott Conklin

unread,
Sep 25, 2010, 4:13:55 PM9/25/10
to framew...@googlegroups.com
i believe this question is somewhat related to this thread so i will ask it here.

I took the skeleton structure from the FW/1 download to create my first project and moved some existing files from a ColdBox project into the appropriate directories.  this means i took what was once:

model
- user
    user.cfc 
     userService.cfc


and spit them into

model
     user.cfc
services
     userService.cfc

the 2 files are a set of generated files created by the Adobe ORM creator.
this means that the service component has a set of functions that take and return the user entity as a data type.

this had all worked fine together before when in the same directory, but now that they are  separated  calling the userService
functions throws and exception  that a function like getuser() is not returning an object of type user.
to get it to work had to prefix the returntype with the parent directory  like so -> model.user

      model.User function getCurrrentUser() output="false" hint="gets the user entity object from persisted scope"  {
                    ....etc,

       
1) I could just make everything  return  "any"  and the problem would also go away but that is not the best solution is it?

2) I thought the ORM settings in the application.cfc for cfclocation where supposed to handle this but i already have it set to
cfclocation="model", should it be something else?

3) should i be rearranging the folder structure so that the services and the ORM entities are together?  i don't think i should have to prefix my functions with pathing details should I? also, it is my understanding the services dir was created for when you may want to use the service() call method and/or implict calls, so they really need to be in this directory if i want to use them this way. correct? doesn't seem right to have to move the user.cfc into the services dir just so they are together...





-------------------------------------
Scott Conklin
socr...@sconklin.com
tel: 713.623.1209

Sean Corfield

unread,
Sep 25, 2010, 4:32:01 PM9/25/10
to framew...@googlegroups.com
On Sat, Sep 25, 2010 at 1:13 PM, Scott Conklin <socr...@sconklin.com> wrote:
> this had all worked fine together before when in the same directory, but now
> that they are  separated  calling the userService
> functions throws and exception  that a function like getuser() is not
> returning an object of type user.
> to get it to work had to prefix the returntype with the parent directory
> like so -> model.user
>
>       model.User function getCurrrentUser() output="false" hint="gets the
> user entity object from persisted scope"  {

Right, because the type is no longer just User (in the same folder) -
because you have the service and the bean in separate folders.

> 2) I thought the ORM settings in the application.cfc for cfclocation where
> supposed to handle this but i already have it set to
> cfclocation="model", should it be something else?

Don't know.

> 3) should i be rearranging the folder structure so that the services and the
> ORM entities are together?

I think best practice would be:

/model
/beans
User.cfc
/services
UserService.cfc

> i don't think i should have to prefix my
> functions with pathing details should I?

Yes, because they're not in the same package - see above.

> services dir was created for when you may want to use the service() call

Huh? The services/ folder is just a convention for FW/1 to find
service CFCs if you expect FW/1 to manage the CFCs for you.

Scott Conklin

unread,
Sep 25, 2010, 4:45:42 PM9/25/10
to framew...@googlegroups.com, Sean Corfield
Huh? The services/ folder is just a convention for FW/1 to find
service CFCs if you expect FW/1 to manage the CFCs for you.
and i am doing that. i stuck my userService.cfc in services dir to be able to call a userValidator function called in onsetuprequest() in application.cfc
like so:
service ('userservice.authorize', 'data');

AND  i have  some calls in controller  components that use the service injected by a DI like so getUserService.getUser()

i guess what you are saying is that if i keep them split then i must prefix them (or make everything "any") .

your best practices suggestion implies that i do not ever want to do the above and places them under model, albeit still separate from one another-- so i still need to qualify them.



-------------------------------------
Scott Conklin
socr...@sconklin.com
tel: 713.623.1209


Reply all
Reply to author
Forward
0 new messages