• Global community
    • Language:
      • Deutsch
      • English
      • Español
      • Français
      • Português
  • 日本語コミュニティ
    Dedicated community for Japanese speakers
  • 한국 커뮤니티
    Dedicated community for Korean speakers
Exit
0

OO-design

New Here ,
Jul 01, 2008 Jul 01, 2008

Copy link to clipboard

Copied

I am developing with an OO-design in mind and I have most of my code written. I have a directory in the webroot
called 'com'.
I want to use/create an object/component in another manager-like object in the same directory. So I have a product component (com/product.cfc) which is just a Bean-like component. I also have a productmanager component (com/productmanager.cfc) which has methods manage products and specifically one to return a product object. What should that method's returntype be? And when i create an instance of a product inside some productmanager method do i call createobject with "com.product" or just "product"?

<cffunction name="getProduct" returntype="com.product" ... >

OR

<cffunction name="getProduct" returntype="product" ... >

I'm guess I'm just missing the basics about when to specify the path and when not to. I create an instance of the productmanager in the application scope and reference that in my display pages. Any body have any advice on best practices here?
TOPICS
Advanced techniques

Views

336

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
New Here ,
Jul 01, 2008 Jul 01, 2008

Copy link to clipboard

Copied

I'm fairly confident that if you don't specify the full path, and the CF server is configured to validate component paths (this is an option in 8) an exception will be thrown.

I've made a habit of specifying full paths for these reasons, as well as to avoid duplicate named component confusion amongst the team.

To further accommodate this setup, we use a central API, which is mapped for all the applications and sites. So we instantiate things such as API.com.mydomain.service. The full path for that component is always available on all sites and environments.

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
LEGEND ,
Jul 01, 2008 Jul 01, 2008

Copy link to clipboard

Copied

> the same directory. So I have a product component (com/product.cfc) which is

You might want to extend that dir structure a bit to include your company
name and your application name:

com.acme.eStore.Product


> to return a product object. What should that method's returntype be? And

com.product

Either will work, but I think the full dotted path is less ambiguous.


> when i create an instance of a product inside some productmanager method do i
> call createobject with "com.product" or just "product"?

Again, I'd use the full path.


> I'm guess I'm just missing the basics about when to specify the path and when
> not to.

I'm not sure there's a "right" way, per se, but deciding on an approach and
sticking with it uniformly is perhaps a good way to do things.


> I create an instance of the productmanager in the application scope
> and reference that in my display pages. Any body have any advice on best
> practices here?

That's a pretty vague question...

--
Adam

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Community Expert ,
Jul 06, 2008 Jul 06, 2008

Copy link to clipboard

Copied

LATEST
Topic Title OO-design
Topic Summary should i specify the whole path or just the component name?


Take as much advice as you can from Vurcease and Adam, but rest assured that what you seek has little or nothing to do with objected-oriented design.





Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Resources
Documentation