Jump to content

  • Log In with Google      Sign In   
  • Create Account

FREE SOFTWARE GIVEAWAY

We have 4 x Pro Licences (valued at $59 each) for 2d modular animation software Spriter to give away in this Thursday's GDNet Direct email newsletter.


Read more in this forum topic or make sure you're signed up (from the right-hand sidebar on the homepage) and read Thursday's newsletter to get in the running!


Count Your Code


Old topic!
Guest, the last post of this topic is over 60 days old and at this point you may not reply in this topic. If you wish to continue this conversation start a new topic.

  • You cannot reply to this topic
24 replies to this topic

#1 vallis   Members   -  Reputation: 122

Posted 09 March 2000 - 02:51 PM

I just knocked up a little program to count how many lines of code there are in a project. Dunno if anyone else would like to play with it or would find it useful but you can get it here if you want it. http://members.xoom.com/blvallis/CodeCounter/CodeCounter.zip If you do use it mail me or leave a message here so I can feel all warm and fuzzy inside

Sponsor:

#2 Fredric   Members   -  Reputation: 122

Posted 09 March 2000 - 03:14 PM

Hey, I''m using it! That''s pretty cool, man! hehe.. I wish I could code as good as you! :p

Programming::~Fredric(const Annoy_Ance)

#3 vallis   Members   -  Reputation: 122

Posted 09 March 2000 - 03:51 PM

Consider me flattered

#4 Spiff   Members   -  Reputation: 122

Posted 09 March 2000 - 07:15 PM

I haven''t tried it yet, but I''d like to because some friends at school always asks me how many lines of code I have written, I personally think that''s pure crap because there''s no way the amount of code can express how good/bad your code is (well, maybe in extreme cases).

Can you make it count Visual Basic source files too, if it''s not too much to ask?

============================
Daniel Netz, Sentinel Design
"I'm not stupid, I'm from Sweden" - Unknown

#5 CGameProgrammer   Members   -  Reputation: 640

Posted 09 March 2000 - 08:03 PM

Also, the number of lines doesn''t even accurately depict how much code there is, since some people write condensed code where many lines are long, whereas others write code spread among many lines, with a lot of white space and comments, and function parameters each on their own line.

But it seems like a useful utility anyway.

~CGameProgrammer( );



#6 vallis   Members   -  Reputation: 122

Posted 09 March 2000 - 09:35 PM

Its true, lines of code are no indicator of skill or amount of work. However it is a ''fun'' way to indicate the progress of a project etc

Spiff - I think that might be a bit difficult because the VB files contain more than source code. I could count the lines in .mod files easy enough but .frm files would take a bit of parsing.

If anybody else wants a VB edition though, post here and Ill do it

#7 vallis   Members   -  Reputation: 122

Posted 09 March 2000 - 10:24 PM

Yeah - I decided i''ll do the VB version tonight. Tell me if im missing anything here:

* Im gonna add a combo box to select C++ or VB mode.
* Im gonna read in the amount of lines in .mod files
* Im gonna read in the amount of lines in .frm files *after* the form declaration section.

Am I missing anything here or is that all?

#8 Spiff   Members   -  Reputation: 122

Posted 09 March 2000 - 10:28 PM

Yep, .cls files too (classes). I''m not really sure if there are any other file types for VB cuz I''m at work now and I can''t check it, but I can do it tonite.

============================
Daniel Netz, Sentinel Design
"I'm not stupid, I'm from Sweden" - Unknown

#9 LackOfKnack   Members   -  Reputation: 122

Posted 09 March 2000 - 11:25 PM

Don''t forget .bas files.


Lack

Christianity, creationism, metric, Dvorak, and BeOS for all!


#10 vallis   Members   -  Reputation: 122

Posted 09 March 2000 - 11:28 PM

Cool - thanks everyone.

If someone could post a full list of extensions then i'll get to work on it...

I take it .bas is the extension for VB modules (not .mod as I thought)

Is there any other programs that I could support as well - may as well make the program complete if i'm gonna do it

I'll probably add assembler .asm support as well

PS - What are peoples thoughts on using multiple directories in their source tree...does anyone use more than one directory to store their source, and therefore should I add functionality for this??

Edited by - vallis on 3/10/00 5:30:18 AM

#11 Kavos   Members   -  Reputation: 122

Posted 09 March 2000 - 11:31 PM

I just create a directory called "Source" and just throw all my source files into there.

Add a character counter as well that ignores whitespace.

more accurate code count


Edited by - Kavos on 3/10/00 5:34:08 AM

#12 vallis   Members   -  Reputation: 122

Posted 09 March 2000 - 11:38 PM

quote:
Original post by Kavos

I just create a directory called "Source" and just throw all my source files into there.

Add a character counter as well that ignores whitespace.

more accurate code count


Edited by - Kavos on 3/10/00 5:34:08 AM

Consider it done. I''ll put all of you on the credits for this thing too


#13 vallis   Members   -  Reputation: 122

Posted 10 March 2000 - 11:55 AM

Hey. All done (nearly)

Just added character counting support, and a few other niceties. Also added preliminary VB support. Havn''t been bothered to parse the FRM files yet so at the moment it includes all of your window details in the count. Ill fix this soon...can anyone suggest a quick way of detecting the start of the code?

I thought about counting the "Begin"''s and "End"''s and when you have matching Begins and Ends you are in the code section. Thats my best one so far...

Also - for VB I currently look at the extensions .BAS .CLS .FRM - are there any others??

Code Counter Version 1.1
http://members.xoom.com/blvallis/CodeCounter/CodeCounter-1_1.zip

Enjoy!

#14 Chris Tutty   Members   -  Reputation: 122

Posted 10 March 2000 - 09:43 PM

In answer to the question about detecting the start of code in VB form files look for lines beginning with ''Attribute''. These follow the form definition and preceed the code (VB5+ only). I dont think you should disregard the form definition though - it provides an indication of the complexity of the form. Perhaps you want to start maintaining different counters for different aspects of the code (how much time where you going to put into this app?)

The cleanest way to analyse VB projects is via the project file (.vbp in VB5,6 and .mak in VB3). This includes the OCX references and project properties as well as a list of all the files which make up the project. Working from this means that you pick up all files regardless of where they are *and* you don''t count files which happen to be in the project directory but aren''t part of the project any longer.

Because I work with large VB projects that share code and use split folders I wrote a utility to copy projects, check for bad file references, compare source intelligently, etc. The code''s pretty crude, but I could cut out the section which parses the project file if that would be useful. Of course it might be faster for you just to pick up a complicated project file and work out it''s structure yourself - there''s really not much to it. Reply here if you want me to email you any of this (I can also provide some sample project files - both VB 3 and 5).

Among all the other things the VB team did right storing the whole project in text files was an often overlooked blessing.

#15 Mezz   Members   -  Reputation: 570

Posted 10 March 2000 - 10:02 PM

Hey, your code counter sounds really cool.

It''s a nifty, fun way to demonstrate the project''s
completion.
But a lot of people say code lines are no indication
of the greatness of the project.
So why not count procedures?
And/Or Classes, structs etc...
Just a little idea for you...

Take it easy,

-Mezz

#16 LaughingD   Members   -  Reputation: 151

Posted 10 March 2000 - 10:10 PM

One thing that would be cool to see is the ability to check all of the sub-directories as well. Large projects generally don't have all of the source in a single directory.

BTW, how are you determining a line? Are you counting semicolons? Carriage returns? Do you include comments in the line count?


Mark Fassett
Laughing Dragon Entertainment
http://www.laughing-dragon.com

Edited by - LaughingD on 3/11/00 4:12:27 AM

Edited by - LaughingD on 3/11/00 4:15:04 AM

#17 vallis   Members   -  Reputation: 122

Posted 11 March 2000 - 05:07 AM

quote:
Original post by LaughingD
BTW, how are you determining a line? Are you counting semicolons? Carriage returns? Do you include comments in the line count?



Currently carriage returns...comments are included.



#18 vallis   Members   -  Reputation: 122

Posted 11 March 2000 - 05:07 AM

quote:
Original post by Mezz

Hey, your code counter sounds really cool.

It''s a nifty, fun way to demonstrate the project''s
completion.
But a lot of people say code lines are no indication
of the greatness of the project.
So why not count procedures?
And/Or Classes, structs etc...
Just a little idea for you...

Take it easy,

-Mezz



Noted for a future version


#19 vallis   Members   -  Reputation: 122

Posted 11 March 2000 - 05:08 AM

quote:
Original post by LaughingD

One thing that would be cool to see is the ability to check all of the sub-directories as well. Large projects generally don''t have all of the source in a single directory.



Yeah - this is what I was asking about earlier...I''ll try and add support for this ASAP.



#20 Spiff   Members   -  Reputation: 122

Posted 11 March 2000 - 11:02 AM

You might wanna add these files too, they''re available in Visual Basic 6 (UserControls and PropertyPages), they work like a .frm file, with the Begin and End.

.ctl
.pag

============================
Daniel Netz, Sentinel Design
"I'm not stupid, I'm from Sweden" - Unknown




Old topic!
Guest, the last post of this topic is over 60 days old and at this point you may not reply in this topic. If you wish to continue this conversation start a new topic.



PARTNERS