What are the characteristics of test code as opposed to production code [closed] - language-agnostic

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 4 years ago.
Improve this question
I would like to know what's the main difference between test and production code in terms of characteristics like why they are different.

A broad question, but let's try.
Production code makes up your product. It gets build, and either goes out to your customers, or serves their requests on (your) server(s).
Test code is "internally", you write it to ensure your production code behaves as expected.
So the purpose is simply completely different. That is the main difference: what that code get used for.
The "rules" that apply when writing that code are mostly similar: you strive for "clean code", simple to understand, easy to change over time.
If at all, there are subtle differences, such as: in production code, you absolutely try to avoid code duplication. Whereas in test code, one core aspect is to quickly understand what a test is doing. A test that does its "setup" outside of the test is harder to understand (because you have to scroll/jump around to collect all "context). So you rather accept duplicated (setup) code here.
In other words: both kinds of code are absolutely crucial for your business. You write all such code with the same level of scrutiny. You strive to achieve the same level of quality (but you understand that certain details are in fact a bit different).
Finally: some people even claim that test code is more important than production code. Your production code, that just implements your requirements. Theoretically, you should be able to throw away one implementation and replace it with a different one.
When you have a great test base, you can actually do that: because your tests represent an executable specification that tells you whether your product does what you expect it to do!

I think a short answer would be that in test code you test the code against expected outcomes so you can check it does what it is supposed to do.
In production the same code just runs and does what it does.

Related

the advantage of reading open source code [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 7 years ago.
Improve this question
I know there is no clear answer to this question. I still wonder to know whether Reading open source code can improve myself rapidly? how and why?
ps:I keep reading open source code every day for months.
Well, many of the bigger open source projects are collaborations between many people: Thus you do have a chance of finding a project written by good developers, and therefore improve your own coding style. Of course, it all depends if you actually memorise the stuff you read or not - But I guess you wouldn't really read that much code if you didn't.
In my opinion, you can learn the following from well-written projects:
Coding conventions
Solutions to common problems (Of course, this depends heavily on the "type" of the project)
How to document code properly - If multiple people work on something, and the project is well-written, it probably also has a good documentation.
Of course, all of this is opinion-based, so you need to see for yourself.
Possible answers (this is highly subjective)
Because working with someone else's code is more difficult than working with my own code. It forces me to adapt to some else's thinking ("If all I have is a hammer, every problem looks like a nail")
Because open-source code is often not written under a deadline, by people who enjoy what they are working at, and can provide high-quality real-world examples
Because open-source code tends to have less of an agenda to push vendor XYZ's proprietary pet technology
Because the world might become a slighly better place, if people wouldn't code for the CPU as their main audience, but a human reader :)

If one has an aim of being a good programmer, what should one prefer, contributing to open source projects or solving codechef.com problems? [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
I am a college student keen to improve my Programming skills. I have two pathways to follow:
Contributing to OpenSource Projects
Solving puzzles at codechef.com
Which one should I follow?
A good programmer is one who cares about his or her ACE - Accuracy, Clarity, Effectiveness.
A good programmer cares about the Accuracy of code. The easy part is coding the "happy path" because this is always in the forefront of our minds when we design and write the code. But what about potential the exception paths that exist when presented with unexpected input and edge case behaviours of the chosen implementation provided? Care is shown by taking the time to think through all the code paths, investing time in testing, submitting the code for peer review, and having the willingness to accept other's suggestions and make changes when appropriate.
A good programmer cares about the Clarity of code. Whether the code is well structured, expressive, adheres to the Open-Closed Principle, the Single Responsibility Principle, the executing machine doesn't care one bit. But, these are all very important to the next programmer, or yourself, who has to read and understand your code at a later date in order to fix bugs, modify behaviours, or add features.
A good programmer cares about the Effectiveness of code. Does it satisfy all the constraints imposed on it? Not only performance and space constraints, but also aspects that make it acceptable to the end user, the demands on the development and testing timelines by your clients, boss, family. Professional software development is not a precise circumscribed task, like "calculate the determinant of an NxN matrix". It has many constraints and demands, and good programmers are mindful of all of these, and will do their best to manage the them, especially when there is not enough time to satisfy all constraints completely.
So! To answer your immediate question, Open Source or codechef, I'd say that being involved in an Open Source project provides much greater opportunities to practice being a good software developer. So go choose an Open Source project that you care about, and ACE it!

Functionality and operation [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 4 years ago.
Improve this question
I'm trying to do some analysis and when writing down a list of functionalities I realized I'm a bit fuzzy on the notion.
What can you consider as functionalities like, say, on this Stackoverflow page? Also, to distinguish between the two, how would you define an operation?
My understanding is that the former is something vague, synonymous with a feature or use-case, defining a distinct need/requirement without going into details. Whereas, the latter is something basic, perhaps a subset of the former, but I wouldn't say it's atomic since an operation could be composed of other operations.
Edit: Here's a link on the subject: http://forum.wordreference.com/showthread.php?t=17873
P.S: Functionality might not be the correct expression in English. If so, please confirm this. "Fonctionalité" is often used with respect to software in the French language.
I'm looking forward to other answers, though I suspect this is more of a language issue than that there are universally defined meanings to these two terms, functionality and operation. Therefore, the following is to be taken as just my personal opinion.
To me, functionality (in the sense that you seem to be talking of, as opposed to the meaning of the word in the linked-to forum discussion) refers to use cases, that is, to something that your product/system offers for achieving some goal. It's not a specific action you can perform, but rather an abstract statement of what a system allows you to do. Related terms are feature, or facility. (Btw. I think for this meaning of the word "functionality", feature would be more appropriate.) For example, you could say:
"This site offers search functionality / has a search feature for finding previously published articles."
An operation (or action?) on the other hand is far more specific. It's not something your system/product offers, but something that is actually done with it. You would probably be talking about operations when you can say exactly how it is to be performed, e.g.:
"A search operation is performed by first entering keywords in this-and-that input field, followed by a click on the 'Go' button."
If you take these two together, you could probably say that "functionality" is an abstract category for a number of concrete "operations" that go towards achieving the same general goal.
But I admit I cannot define the two terms more precisely, either; esp. with regards to choosing the right "granularity" for defining specific functionalties or features.

Making a Difference # Open Source Projects [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
Can I make a difference at an open source project?
I haven't gotten a degree or anything but I am really interested in computer science and I have most of the fundamentals down.
Is there a project I can make a difference at? If not, any sites where I can further my knowledge and review the fundamentals (advanced concepts as well) of computer programming?
Scour around GitHub for projects, there are plenty that could use some help.
At the very least, write tests for untested code and submit them back. Even the littlest of contributions are appreciated.
Newcomers to an active Open Source project often feel like they are walking into a busy kitchen. A lot of different things going on and you feel like you are just in the way.
But often its not the case.
I can't point you to a specific project since i do not know your skillset or what you want to focus on.
Getting into an Open Source project can take time, its mostly based on the size of the project but usually its trying to see what is needed.
What i recommend is the same most people do, find a project that inspires you to make it better (even though its good to begin with), since that will make you want to stick around during the harder times.
Absolutely. Writing documentation and unit tests is good advice, but I'd suggest instead you find something you're particularly interested in, perhaps a piece of open source software you already use, and add a feature that you yourself want to use. It'll be more difficult, but it'll actually keep your interest and get you real world experience. Worst case your patch won't be accepted, but if it's a decent project they'll tell you why and what you need to do to make it acceptable.
Or, pick a small problem you want to see solved, and write an open source solution for it. The key is actually be interested in the problem you're solving.
Open source software is not magically high quality code; in fact it's not unusual to find sloppy code and practices. Don't be intimidated, jump in and give it a try. My first piece of open source still has a few users over 10 years later, but the code quality makes me cringe everytime I look at it.
You can visit Sourceforge.net and look for projects that need help.

What is your "generic" web application testing plan? [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 9 years ago.
Improve this question
Like, testing for :
invalid inputs (strings containing "'"s)
giving random id's in url parameters to access "unauthorized" pages
prevent sql injection
...
I would recommend reading this brilliant book to learn more about the test plans.
In particular a test plan is much more than a list of techniques like you mentioned (these should most likely go into the details for the security testing)
It should at least contain:
The answers to the main questions:
why bother (what is gained by testing)
who cares (who are we working for)
how much (..testing will be done)
You would not go wrong providing also:
Platforms
Methods (positive testing, load testing etc)
Functionality you're planning to test
Acceptance criteria
And there is plenty more things to talk about in the plan.
Test responses for:
For integers - strings, null, values more than those allowed, negative, zero..
For strings - strings of lengths longer than that allowed
For invalid values, you can check if the response being returned is informative enough.
Test to see that your application logs these errors. If it doesn't you won't be able to identify and debug problems easily when they occur in production.
Also fuzz testing is a must for web applications.
If you want to make a list, you can add "Trying simple javascripts within a textarea field to see if the site saves and executes them"
this is what i use
Quality Test Plan
its very simple, straight-forward. covers many common web flaws (e.g. broken links, etc)
you might think its too basic, but im always surprised how many bugs it reveals
--LM