Jump to content

Best Practices - Inheriting from a Class that Lives in a Package


benhysell

Recommended Posts

[cross posted: http://forums.lavag.org/Best-Practices-Inh...age-t13410.html]

 

Goal: Create a set of packages that I can distribute to my team that we will use to start off every new project.

 

Scenarios: I have a set of base classes that we are going to inherit from to generate new code for each new project. As an example, I have a database class. This class has all of the features to allow one to create, read, update, and delete (typical CRUD) and item to move into our out of the database. This base class describes the functionality and provides the API for the rest of the application to call, and based on the object supplied it will perform the proper operation on the database.

 

This separation also allows for unit testing of the database interactions...I can mock out the database calls during the testing phase of the project if there is a common API for all CRUD for every object going in and out of the database.

 

Motivation: In my world, the developer has a framework of where to put their CRUD and what VIs they need to overwrite to get their item into our out of the database. Now we have a framework where any developer on the project comes in, opens up someone else's code and goes 'where is the update call for foo1', they goto the class for 'foo1' and lookup the update.vi that has been overriden from the parent class.

 

Each item that goes into our out of the database has their own CRUD VIs, since each item is different and needs to be inserted and queried from the database in different ways.

 

Question: What is the best practice to inherit in a project a class that lives in a package? I have found through playing around I cannot inherit from a class in a package, that I actually need to create a VI (I've been calling it 'includes.vi') lay down a reference to the class in the package, and then I can inherit from it in the project. Is there a better way?

 

Is this a common use of the Package methodology? Would I be better off sending out Project Libraries to my developers?

 

-ben

Link to comment
Share on other sites

Hi Ben,

 

Creating packages from reusable base classes is a great way to distribute them to your team and other projects.

 

Regarding inheriting from a base class, in order to set a class as a parent, the new parent must be in memory within the project -- that's just a limitation of LabVIEW. Typically, I'll just add base classes into a virtual folder, right from the get go. This provides easy access to the base class methods.

 

Thanks,

 

-Jim

Link to comment
Share on other sites

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...

Important Information

By using this site, you agree to our Terms of Use.