Another stupid question about code formating

Discuss the Firewing development environment

Another stupid question about code formating

Postby Timbo » Sun Apr 26, 2015 8:01 am

Hi,

This is just a general "how do you do it" question.

When you write code for a project what's your format for its layout.

Some background to help me explain my question. In my coding for another compiler. I would mostly just have one file, I suppose one of the reasons is that ISIS VSM would always give issues with includes but another reason would be that I could easily jump around the code and portability of the code, Less files to have to remember to pack up the better.

I normal write like this:-

OSC speeds Coff enabling that kind of stuff
Defining Pic regs
Variable defs
Constants etc
Eeprom allocations

Jump to main
Interrupt code High/Low
All subs
Initialization

Main Loop

Data Tables

Now Firewing offers so much better structure ability, but I'm lost on the best formating. Do you code it all in one file, Are you always making modules, Do you place subs, functions etc below your main code.

If you do not mind sharing any old projects that show your system I would appreciate it.

Thanks

Tim
Timbo
 
Posts: 93
Joined: Fri May 03, 2013 7:51 pm

Re: Another stupid question about code formating

Postby Jerry Messina » Sun Apr 26, 2015 11:13 pm

It takes a bit of thought and effort transitioning from the "one big flat file" model to a modular approach but trust me, once you get the hang of it you'll never want to go back. There are just so many advantages to arranging your code into modules they're almost too numerous to mention.

As far as the arrangement goes, in general you have a lot of freedom, and some things are just personal preference. For example, you might find that your "Defining Pic Regs" section is something you want to share among different modules so perhaps it should go into its own module. As you divide things up into modules some of this will sort itself out almost by itself as you begin to see what belongs where. The best thing is probably to read through some of the samples and try it out for yourself. You'll soon find out what works or doesn't, and we're always here to help.

Not much help in answering your question, I know, but there's no one size fits all. I have some really simple projects that are basically done as a single file, and others that are a few hundred different modules. For the latter I can't imagine ever doing that with a single file structure!

PS - how are things going w/ getting ISIS working?
Jerry Messina
 
Posts: 280
Joined: Thu Feb 14, 2013 10:16 am

Re: Another stupid question about code formating

Postby Timbo » Mon Apr 27, 2015 7:38 am

Hi Jerry

Your post was very helpful. Its made it clear the direction I need to go in. The thing I must not do is get hung up on doing it absolutely right from the start. I'm procrastinating as it is. So I will learn on the go. Its been a year since I did any serious coding so getting myself engaged again is hard.

So no luck with getting Firewing to compile with another compiler. It keeps throwing up errors, I will have to go back and look at what the errors were later. So for now I'm going to code for the 18 series so I can run see what's going on in ISIS. I actually do not have the right pic in ISIS but there is one close enough to make it run.

Thanks again.
Timbo
 
Posts: 93
Joined: Fri May 03, 2013 7:51 pm


Return to Development Environment

Who is online

Users browsing this forum: No registered users and 1 guest

cron

x