This Forum is Dedicated For all The Object Oriented PIC Lovers .......... The concept behind OOPic is straight forward. Use preprogrammed multitasking Objects from a library of highly optimized Objects to do all the work of interacting with the hardware. Then write small scripts in Basic, C, or Java syntax styles to control the Objects. During operation, the Objects run continuously and simultaneously in the background while the scripts run in the foreground telling the objects what to do.

Sunday, July 20, 2008

[oopic] Re: Optimizing code

> I read somewhere in the docs that use of constants can save variable
> memory, but if it ain't working I'll go with whatever is easier.

THAT is true! To assign a constant to a variable and use it as a
constant wastes the storage space of a Byte or oByte (Word or oWord,
also).

Dim MyNamedConstantInAVariable as new oByte

sub main()
MyNamedConstantInAVariable = 3 'and I will NEVER change it!
end sub


But whether you use a named constant (const MyConstant = 3) or a
literal (3) in an expression would probably not make any difference at
all:

a = MyConstant
versus
a = 3

Named constants are nice because they help document the code. At
least they should! Literals are to be avoided as a matter of
practice. Many consider them 'magic numbers' and really hate to see
them in code. It's often impossible to determine what they mean.
Well, sometimes it is obvious but not always.

>
> I have some 32k EEPROMs so I can go wild with programming and data
> space. Now I have some work to do! Like I said, speed isn't a
> priority (unless we are REALLY talking slow!) but I do want to try
> coding some more advanced 'behavior' using the available variables
> and objects.

Figure on 300 lines per second. But having code for different
behaviors that operate independently won't slow the machine. It's
just a different group of code. The only cost is in determining which
behavior to execute. That should be short and fast.

Richard


------------------------------------

Yahoo! Groups Links

<*> To visit your group on the web, go to:
http://groups.yahoo.com/group/oopic/

<*> Your email settings:
Individual Email | Traditional

<*> To change settings online go to:
http://groups.yahoo.com/group/oopic/join
(Yahoo! ID required)

<*> To change settings via email:
mailto:oopic-digest@yahoogroups.com
mailto:oopic-fullfeatured@yahoogroups.com

<*> To unsubscribe from this group, send an email to:
oopic-unsubscribe@yahoogroups.com

<*> Your use of Yahoo! Groups is subject to:
http://docs.yahoo.com/info/terms/

No comments: