Max line count of one file? [closed] - coding-style

Closed. This question is opinion-based. It is not currently accepting answers.
Want to improve this question? Update the question so it can be answered with facts and citations by editing this post.
Closed 3 years ago.
Improve this question
How many max number of lines of code one .cs file should hold. Are there any industry standards/best practices?

I don't know how much, but there is a number which is considered a best practice.
It's all about maintainability, and there's much more to it than the number of lines in a source file. What about number of methods in a class? Cyclomatic complexity of a method? Number of classes in a project?
It's best to run a code metrics tool on your source code to find out more, like NDepend.

As few as possible to do the job required whilst remaining readable.
If you're spilling over into the thousands upon thousands of line you might want to ask yourself what exactly this file is doing and how can you split it up to express the activity better.
Day to day, if I find a class which is more than 1000 lines long I am always suspicious that either the class is responsible for too much, or the responsibility is expressed badly.
However as with every rule of thumb, each case should be assessed on it's own merits.

Related

Which way is more efficient to learn data structures? [closed]

Closed. This question is opinion-based. It is not currently accepting answers.
Want to improve this question? Update the question so it can be answered with facts and citations by editing this post.
Closed 2 years ago.
Improve this question
My programming knowledge is up to OOP since that was the last thing we covered in the university. However, I am taking 2 courses this summer and I am constantly under pressure, but I am planning to learn data structures along the way too, to be prepared for it next semester.
I had two plans to learn it but I am not sure which one will be more efficient:
-The first one is to skim through and learn about all the types of data structures and how they are implemented.
-The second one is to try instead of just reading and knowing about a data structure, I will go and try to implement it. However, the drawbacks are that its slow and time consuming, so I might not be able to learn all of the data structures in time
Practice using the data structures in your code.
Code those data structures from scratch.
Repeat steps 1 and 2.
There is really no shortcut for that.

Split text files into two groups - unsupervised learning [closed]

Closed. This question needs to be more focused. It is not currently accepting answers.
Want to improve this question? Update the question so it focuses on one problem only by editing this post.
Closed 5 years ago.
Improve this question
Imagine, you are a librarian and during time you
have classified a bunch of text files (approx 100)
with a general ambiguous keyword.
Every text file is actually a topic of keyword_meaning1
or a topic of keyword_meaning2.
Which unsupervised learning approach would you use,
to split the text files into two groups?
What precision (in percentage) of correct classification
can be achieved according to a number of text files?
Or can be somehow indicated in one group, that there is
a need of a librarian to check certain files, because
they may be classifed incorrectly?
The easiest starting point would be to use a naive Bayes classifier. It's hard to speculate about the expected precision. You have to test it yourself. Just get a program for e-mail spam detection and try it out. For example, SpamBayes (http://spambayes.sourceforge.net/) is a quite good starting point and easily hackable. SpamBayes has a nice feature that it will label messages as "unsure" when there is no clear separation between two classes.
Edit: When you really want unsupervised clustering method, then perhaps something like Carrot2 (http://project.carrot2.org/) is more appropriate.

Writing an algorithm to complete a checklist, where to start? [closed]

Closed. This question needs to be more focused. It is not currently accepting answers.
Want to improve this question? Update the question so it focuses on one problem only by editing this post.
Closed 7 years ago.
Improve this question
I'm completing a dissertation in health economics and would like to explore the possibility of using an algorithm to answer a checklist that I manually filled in during my research.
The checklist is a 24-item checklist which asks questions such as "Was a discount rate reported?". Now, the articles I've been reviewing tend to be very codified. That is, there are only a few ways that they report an answer (e.g. "we discounted at 3% in this evaluation").
Theoretically, I think it would be possible to write a program that could search text and fill out the majority of these checklist items. However, I have very little experience in programming. As far as I can see, a program like this would involve writing an algorithm of sorts, but that is where my knowledge ends.
Particularly, I would like to know
- Is this possible?
- If so, how would I go about exploring this further? Ideally, I'd like to get to a point where I could play around with writing an algorithm to look through my database.
This could definitely be done with simple logic and parsing, but the key to it would be that the manual entries are consistent in the way that they are "codified".
For example, you'd parse your line for a specific token (or validation word).
In your case above you could parse word for word the string: "we discounted at 3% in this evaluation"
Code wise we could implement a basic logical comparison to each word parsed in the string.
if(currentWord is equal to "discounted")
create a checkmark.

Style of writing conditional operators [closed]

Closed. This question is opinion-based. It is not currently accepting answers.
Want to improve this question? Update the question so it can be answered with facts and citations by editing this post.
Closed 8 years ago.
Improve this question
What is considered more appropriate style of writing conditional operators?
if(1){
puts("Hello")
}
or
if(1) puts("Hello")
Similar aspects of coding style are welcome too.
That's all depends on your preference, that's why we rarely see people code in the same style.. Moreover, it depends on which programming language you're using.. IMHO, the important thing in coding is code readability and comments, so when your BOSS asks other people to help or develop your code. He /she will spend the least amount of their time to understand your code..
If you ask specifically from your example above, I would prefer the first one.. Because in my OPINION, imagining the WHOLE code, that one will give better readability. HOWEVER, some people may argue that it will spend some of your time typing those brackets over and over..
As per the PSR standards any structure must always enclose the code in parentheses.
The body of each structure MUST be enclosed by braces. This standardizes how the structures look, and reduces the likelihood of introducing errors as new lines get added to the body.
from the official website
Please have a look under control structures section http://www.php-fig.org/psr/psr-2/

I.Y.H.O, what phase of software development takes the most time (besides maintenance)? [closed]

Closed. This question is opinion-based. It is not currently accepting answers.
Want to improve this question? Update the question so it can be answered with facts and citations by editing this post.
Closed 6 years ago.
Improve this question
In your experience, what phase of software development takes the most time? That is besides maintenance, of course. And which phase takes the second most time? Which methodology do you use?
The final 20% always takes the longest - roughly 80% of the total time of the project.
I don't think there is any methodology that will change this. As a project begins to take its final form and is demoed its always easier for clients to think of new ideas and improvements. I think the best way to handle it is to keep open communication with the client, be open to change suggestions, but make sure they are aware that their changes will increase the development cost.

Resources