Re: programming style
- Posted by codepilot Gmail Account <codepilot at gmail.com> Oct 26, 2004
- 515 views
I was never really into commenting, the only comments I make are commented out lines of code, save the tutorials that have a light drizzling here and there. Dan On Mon, 25 Oct 2004 13:38:23 -0700, Tone =C5=A0koda <guest at rapideuphoria.co= m> wrote: > > posted by: Tone =C5=A0koda <tskoda at email.si> > > I developed this programming style which made my coding much easier: > I comment blocks of code. And I make it so that it is clear for which blo= ck of code the comment is for. Blocks of code and their comments can be org= anized in tree. This style is especially useful if you write complicated co= de. If I didn't use this style then coding complicated things would be a ni= ghtmare. > > --// > --// Comment: > --//=> > ...here is block of code... > ...here is block of code... > ...here is block of code... > ...other code continues here... > > Here's a real example: > > }}} <eucode> > --// Converts 'potentn_workobj' to work object and adds > --// it to 'All_work_objects'. > --// Updates global variables 'All_work_objects', 'Potent_workobjs' > --// and sometimes 'Final_objects'. > procedure add_wobj (POTWOBJ potentn_workobj) > TOP_WOBJ new_wobj > TOP_WORK_OBJECT_IDX new_wobj_idx > TOP_WOBJS_IDXS new_wobj_neighs_idxs > TOP_WOBJ_IDX child1_wobj_idx > TOP_WOBJ_IDX child2_wobj_idx > TOP_WOBJ_IDX cmp_child1_wobj_idx > TOP_WOBJ_IDX cmp_child2_wobj_idx > POTWOBJS_IDXS remove_potwobjs_idxs > POTWOBJS new_potent_workobjs > --// > --// Update 'All_work_objects': > --//=> > new_wobj = convert_potwobj_to_wobj (potentn_workobj) > All_work_objects = append (All_work_objects, new_wobj) > --// > --// Update 'Potent_workobjs'. > --// We only need to check those potential work objects, > --// which are made of work objects whose neighbour changed, > --// ie who have new neighbour 'new_wobj', > --// AND those potential work objects which > --// were made of work objects which were part of > --// 'potentn_workobj'. > --//=> > --// > --// Get indexes of work objects which need to be checked: > --//=> > new_wobj_neighs_idxs = get_work_obj_neighs_indexes (new_wobj= ) > child1_wobj_idx = potwobj [POTWOBJ_CHILD1] > child2_wobj_idx = potwobj [POTWOBJ_CHILD2] > new_wobj_idx = length (All_work_objects) > if Debug then > assert (equal (All_work_objects [length (All_work_objects)= ], > All_work_objects [new_wobj_idx])) > end if > --// > --// Remove old: > --//=> > --// > --// Get 'remove_potwobjs_idxs': > --//=> > remove_potwobjs_idxs = {} > for i = 1 to length (Potent_workobjs) do > cmp_potwobj = Potent_workobjs [i] > cmp_child1_wobj_idx = cmp_potwobj [POTWOBJ_CHILD1] > cmp_child2_wobj_idx = cmp_potwobj [POTWOBJ_CHILD2] > if cmp_child1_wobj_idx = child1_wobj_idx > or cmp_child1_wobj_idx = child2_wobj_idx > or cmp_child2_wobj_idx = child1_wobj_idx > or cmp_child2_wobj_idx = child2_wobj_idx > or find (cmp_child1_wobj_idx, new_wobj_neighs_idxs) > or find (cmp_child2_wobj_idx, new_wobj_neighs_idxs) th= en > remove_potwobjs_idxs = append (remove_potwobjs_i= dxs, i) > end if > end for > --// > --// Remove: > --//=> > Potent_workobjs = remove_members (remove_potwobjs_idxs, = Potent_workobjs) > --// > --// Add new: > --//=> > --// > --// Get 'relink_wobjs_idxs': > --//=> > relink_wobjs_idxs = new_wobj_neighs_idxs > relink_wobjs_idxs = append (relink_wobjs_idxs, new_wobj_= idx) > --// > --// Get 'new_potent_workobjs': > --//=> > TODO > --// > --// Add: > --//=> > Potent_workobjs = sorted_seq_insert (new_potent_workobjs= , Potent_workobjs, Potent_workobjs_cmp_routid) > --// > --// Update 'Final_objects': > --//=> > TODO > end procedure > </eucode> {{{ > > > > >