2

I have to Write a program (in C#) to count (in LOC) the • total program size • total size of each of the program’s parts (classes, functions, or procedures) • the number of items (or methods) in each part.

Produce and print • a single count for the entire program • size and item counts for each part together with the part name

But I really don't know how to do it.

Any idea?

JasonMArcher
  • 14,195
  • 22
  • 56
  • 52
Jean
  • 593
  • 2
  • 6
  • 19
  • You could use a Regular Expression. – User 12345678 Sep 10 '13 at 17:48
  • Homework? You should at least say what you've tried, but here's a hint: read each line, determine if it's a "LOC" or not. You'll need to track things like the start and end of comments. For methods, you'll need to track how deeply nested the curly braces are (+1 for every {, -1 for every }, when you reach 0, you've ended a method). – Tawnos Sep 10 '13 at 17:49
  • 1
    Determining what constitutes a line of code is also a problem. Does a curly brace by itself count? Do you include or exclude comments (arguably comments are as valuable as code, don't want to discourage leaving comments). – Gary Walker Sep 10 '13 at 18:00
  • To add to @GaryWalker said, what about code that's broken down into multiple lines? Is that one line of code, or multiple? – Bob. Sep 10 '13 at 18:48
  • Hey guys, thank you. You helped me so much. I defined all these things about "{s" and "/* */", LOC, and more in a code standard. My app now count the total Lines Of Code, and blocks (starting with "{" and finishing with "}") **But what about the number of items (or methods) in each part, Produce and print a single count for the entire program, and produce and print size and item counts for each part together with the part name?** How could I do it? I don't understand – Jean Sep 11 '13 at 16:38

0 Answers0