vb.Net Coding Standards  Topic is solved

Discussions relating to Jiwa 7 plugin development, and the Jiwa 7 API.

vb.Net Coding Standards

Postby Clare » Tue Jan 12, 2016 4:59 pm

Hi all,

Does Jiwa have some vb.Net coding standards it adheres to?

If so are we able to get a copy? We are currently reviewing our own.

Thanks
Clare
Clare
I'm new here
I'm new here
 
Posts: 9
Joined: Tue Jan 12, 2016 4:54 pm
Topics Solved: 1

Re: vb.Net Coding Standards  Topic is solved

Postby Mike.Sheen » Tue Jan 12, 2016 7:52 pm

Clare wrote:Does Jiwa have some vb.Net coding standards it adheres to?

If so are we able to get a copy? We are currently reviewing our own.


Hi Clare, and welcome to the Jiwa forums.

We do not have a formal, documented coding standard, but we loosely follow the Microsoft VB.NET coding conventions guidelines. An exception to this is when writing plugins, you should contravene the linked guidance and not use the handles keywords when adding event handlers, but explicitly use AddHandler or your handler will not execute in the order as defined by the "Execution Order" property of the plugin. If you are using the Jiwa API not from within a plugin, then you're free to use the handles keyword with no unexpected results.

As a lot of the Jiwa API is ported from legacy code, there are inconsistencies in some of that code - so be wary of copying the conventions some of our API exhibits. Newly rewritten areas are a good guide (such as Bill Of Materials, Supplier Returns), but older areas (such as Cash Book or Stock Transfer) are not so good. When writing new code, we tend to follow these rules:

  • Tables and objects are named in the singular, not the plural : e.g.: Customer and not Customers
  • Collections are suffixed with Collection : e.g.: CustomerCollection
  • Classes, Methods and properties are named with CamelCase
  • Methods are verbs : e.g.: Save(), GetListOfDebtorsOnHold(), CalculatePeriodBalance()
  • Properties are simply named for their context : e.g.: Name and not DebtorName (that's just redundant)
  • Within plugins, handle exceptions only when necessary, and if catching an exception use Throw or Throw new Exception("meaningful message", ex) instead of just Throw(ex) to cause the exception to bubble up and be handled. Unhandled exceptions in plugins are managed for you, and will perform required cleanup actions and error message display automatically.
  • Within plugins, Throw a new JiwaFinancials.Jiwa.JiwaApplication.Exception.ClientCancelledException to cancel/fail silently - this is necessary when you want to run your code before the standard Jiwa code, and not have the standard Jiwa code run afterwards (e.g.: intercepting a button click in the UI to run your code instead).
  • Use the factories to create business logic objects, forms and dialogs.
  • Don't ever commit or rollback database transactions unless you created the transaction. If you want a rollback and you didn't create the transaction, throw an exception.
  • If you create a transaction, you are responsible for rollbacks and commits - use Try Catch to guarantee you have control over exceptions raised after creating a transaction.

That's a short list of the important items I can readily think of.

Mike
Mike Sheen
Chief Software Engineer
Jiwa Financials

If I do answer your question to your satisfaction, please mark it as the post solving the topic so others with the same issue can readily identify the solution
User avatar
Mike.Sheen
Overflow Error
Overflow Error
 
Posts: 2583
Joined: Tue Feb 12, 2008 11:12 am
Location: Perth, Republic of Western Australia
Topics Solved: 807


Return to Technical and or Programming

Who is online

Users browsing this forum: No registered users and 1 guest