Some tips and tricks in naming your objects well while developing code for Business Central.
First you need a pre/post fix from Microsoft. Well you only need this if you are developing things that go into AppSource, however just get it, so we don’t have conflicting objects out there.
So why is this important. Well if 2 objects have the same name one of the 2 extensions cannot install and we will have an issue.
So lets look at how you should name your objects.
First you get your pre/post fix from Microsoft. In my case this could be IB. You would than think I can create an object named IBSetup or SetupIB and I would never have a conflict. Well they assumption is that you likely would develop more extensions at your company, so this is not quite enough. Let’s say I am developing a Label extension. Well in that case I could reserve IBLBL as my prefix IB required my Microsoft and LBL I can track internally as my Label extension. If I now have a Setup object I can call it IBLBLSetup and I know it is unique.
Well that is a little hard to read in my book so I prefer IBLBL_Setup. Why underscore is a good idea is because I don’t need quotes around the name as you would if you selected to use a dot. “IBLBL.Setup” If you use underscore you can also quickly double click the variable to mark it up if needed something that doesn’t work if you use a dot. I use that all the time when I need to copy a variable.
Last but not least prefix or post fix. Why not call it Setup_LBLIB. (Beaware the IB must be first or last.) Personally I prefer post fixes but it is just something you need to agree on company wide as mixing these up just creates total confusion.
We use prefixes because that was decided at some point and we are not about to change it.
Field names should be treated the same however you only need to follow the standard for fieldnames that are extending existing objects. If the object is all yours pre or post fixes are not needed.
Hopefully this helps some of you in naming your objects in good ways when you start extension development.
you know there is automatic pre-/suffixing in the crs-al-language-extension? 😉
Of course I do 🙂
Well… I for one just found out 😀 Thanks Waldo & Soren