答:
Binaries are generally not well suited for version control system because:

they don't benefit from version control features (merge, diff)

they increase the size of the repo...

... which matters because you don't remove easily a version from a VCS (VCS are made to keep the history), as opposed to artifact repositories like Nexus, which are simple shared directories (easy to clean up: cd + rm!)

they should be referenced in a VCS as a text, a declaration of path+version: you can keep relevant history that way, recording any change of binary version as a change in that text file (like a pom.xml if you are using Nexus for instance)

OwnerDisplayName: VonC


问:
Is it good practice to store framework runtimes under source control?
I know a lot of software shops keep binaries under source control. However, our shop had come to store entire frameworks on the repository: DirectX runtime, CUDA, nVidia Optix, whatever.

It is said to make a dev machine setup easier (supposedly, get latest and start coding). However, it considerably bloats the repository and burdens it with irrelevant history.

I've never seen such a usage pattern. Do you consider it a good practice?

[EDIT:] I have no problem with source-controlling isolated 3rd party binaries. The question refers to entire framework runtimes, typically consisting in 10+ binaries.    As an extreme example, take Windows SDK (which we don't keep on the repository, thank god, but I see no difference in principle).

答:
It is generally a good idea to do configuration management with framework versions. If your code needs a specific DirectX version, that version should be easily available, and if you check out an older version of your software, it should be easy to determine which external dependencies it has.

What I don't think to be a good idea here is to use your typical versioning control system for storing those binaries.  In our company, we store every version of frameworks, libraries and external tools in a subfolder structure on a network drive. Where we think it makes sense, we have readme files to document which tool version belongs to which software version, or, if possible, we have scripts for installing or using a specific version. Only those readme files and scripts go into version control.

We also keep older versions of tools and libraries as long as we think there may be a chance we must rebuild and older version depending on those tools. That way it gives us the possibility to delete some of the very old libs&tools from our network drive when they got deprecated (of course, just in case we have archives on external media).

OwnerDisplayName: Ofek Shilon

ContentLicense: CC BY-SA 3.0

OwnerDisplayName: Doc Brown


问:
What does a code review look like?
I'm writing a code review process document for our team; we've never had a formal process in place although we do do some code review.

I've found lots of articles talking about how important code review is, but I have one question in particular that I haven't found the answer to on the web... is the programmer part of the code review? In other words, should a code review be 2 people sitting together, going over what's in the code, or should it be 1 person looking at another person's code?

Most often, our projects are done by a team of 2 people, so before it is sent to QA, should those 2 people just sit together and go over the entire project, including what each of them have written? Or, should they just both look at each other's code? I can see advantages to each.

Finally, what happens with issues found during code review? Are they noted, and then sent back to the programmer? Or should the reviewer note them and then just fix them? Or is it ever ok to make a change and not even tell the programmer specifically what you found?

答:
The simplest way to do a code review is to get a tool (I used codestriker). Then the process is :

the programmer picks the code for the review and reviewers

reviewers comment the code

programmer goes through the comments and accepts whats appropriate

This way, reviewers can do it when they find time for it. And programmer do not need to take notes.

An alternative to code review is pair programming. Some people call it code review on steroids, but it is much more then that.

Title: What does a code review look like?


答:
There is a good reason for doing this, namely that you have all you need in a single location, without any external dependencies.

This is much more important than you may think.  It essentially ensures that you do not rely on an artifact on a vendor server which may go away after a few years, since you have everything in-house.

Regarding repository bloat.  This is only a problem if your VCS keeps a full local copy (git does this, cvs doesn't) since cloning and/or updating will be slow.  In return you will have copies on each development machine, which may save your company if your central backup scheme for some reason fails some day.

It is a matter of priority or policy.  As long as the decision is deliberate, I would be fine with this.

Title: Is it good practice to store framework runtimes under source control?

Body:
I know a lot of software shops keep binaries under source control. However, our shop had come to store entire frameworks on the repository: DirectX runtime, CUDA, nVidia Optix, whatever.

It is said to make a dev machine setup easier (supposedly, get latest and start coding). However, it considerably bloats the repository and burdens it with irrelevant history.

I've never seen such a usage pattern. Do you consider it a good practice?

[EDIT:] I have no problem with source-controlling isolated 3rd party binaries. The question refers to entire framework runtimes, typically consisting in 10+ binaries.    As an extreme example, take Windows SDK (which we don't keep on the repository, thank god, but I see no difference in principle).


问:
What is the best way to evaluate new programmers?
What is the best way to evaluate the best candidates to get a new job (talking merely in terms of programming skills)?  In my company we have had a lot of bad experiences with people who have good grades but do not have real programming skills.  Their skills are merely like code monkeys, without the ability to analyze the problems and find solutions.

More things that I have to note:

The education system in my country sucks--really sucks.  The
people that are good in this kind of job are good because they have talent for it
or really try to learn on their own.

The university / graduate /post-grad degree doesn't mean necessarily that you know exactly how to do the things.

Certifications also mean nothing here because the people in charge of the certification course also don't have skills (or are in low paying jobs).

We need really to get the good candidates that are flexible and don't have mechanical thinking (because this type of people by experience have a low performance).

We are in a government institution and the people that are candidates don't necessarily come from outside, but we have the possibility to accept or not any candidates until we find the correct one.

答:
I'm not sure if this is a comment or answer but basically what Matthieu said. You want stupid easy questions that take a minute or two (but no longer than 5) minutes to do and they should be about different areas.

Such examples of stupid easy question is a question about recursion such as you have a list and you must print it reverse order without using a loop. A simple regex question if regex is normally done in your development. A question about bits and bytes if using C++ (write a template that accepts char to long and prints out the binary representation. Specialization isnt required, just use sizeof() to figure out the bit length)

It should take you about <=3minutes per question

ContentLicense: CC BY-SA 4.0


问:
Overcome clumsiness in writing code
I believe this is a little related with this question: How to be a zero-bug programmer?.
But I believe this is more regarding clumsiness in programming because I know it is impossible to become a zero bug programmer.

Often, I write a very buggy code caused by my own clumsiness. For example in writing a currency rate conversion function, a trivial function. I can code the function that running well given the correct value. But sometime I just forgot to validate some unexpected-but-reasonable values.

So are there any ways for clumsy programmer like me to write and test the code more thoroughly?

Additional
I see a lot of people suggesting to write unit test or using TDD approach. But writing unit-test not always goes well because of clumsiness isn't it? I don't because I once tried to write unit-test, but still often bumps with bugs.

答:
The real answer is very simple and boring and doesn't involve tons of lists and instructions.

Code every day for 10 years and you will be great at it. That's it. You will end up figuring everything out along the way and refactor and refine yourself. Its the nature of the human brain.

Bruce Lee ended up figuring out that there is no one style of fighting, you have to adapt to your opponent.

In programming, there is no one style, you adapt to your problem. But you have to have done it for a long time to be a master at it.

That's it.

Title: Overcome clumsiness in writing code


问:
How to properly validate your code?
I have about 4000 lines of code for a web-application in JavaScript / PHP / CSS / HTML.  How can I test it properly?

I only support the latest version of IE and Safari.  I've worked out all the bugs. Is there a good way to test it so that I could go so far as to call the code robust?

I've considered using perl Mechanize to auto fill in forms or do something similar.

I also have a PHP test class to test the inner working of my PHP classes.  However is there some sort of standard or conformance guidelines to be met? Is there a way to say this code passes IEEE xxx foo standards for code robsustness etc.?

I have validated my HTML using W3 validators and I've validated my JavaScript using jslint.com.

Here is list of dilligence items:

HTML / CSS passes W3 validation

JavaScript passes jslint

PHP passes internal PHP Test Class

User Testing

Create a set of User Actions and Implement using perl mechanize or similar.

Are there standards or procedures for releasing code to the web?

答:
The answer is not popular.

You must have users beat the living hell out of it. After you have exhausted the list of bugs reported after many iterations of testing, you then can only call your code robust.

You testing it alone will be of little use because you are in the trees coding and cannot see the forest.

Don't you know developers are the worst testers ever? I'm a developer and I know this only after many years of falling on my face after stating proudly, "this work perfectly on my laptop".

Title: How to properly validate your code?


问:
Is the COCOMO model a good argument when defending a programming language choice?
Currently, I'm following a course on embedded software development. The lecturer has chosen J as an architecture language for model-driven software development. J itself is a very terse programming language and one of his main arguments for this language is its terseness. For instance, this is a Quicksoft implementation in J:

```<code>quicksort=: (($:@(<#[) , (=#[) , $:@(>#[)) ({~ ?@#)) ^: (1<#)
</code>```

Another argument is that through such a language and the reduced number of characters, you introduce less bugs and the time to fix bugs is reduced.

Since I have a strong software engineering background and through various books like Clean Code, Pragmatic Programmer and others, I feel that these arguments aren't valid. I find that there is a strong movement towards descriptive names and code that reads like natural language (alright, this might only be related to applications with lots of business logic and less math).

The question therefore is, can you really argue that usage of a terse programming language will result in less errors and that time to fix a bug is reduced? Also, since the language is terse, the number of lines of code is reduced and you would get a better COCOMO rating. But can this be applied in the first place or does the COCOMO model use the number of lines of code as a way to estimate a project's overall size (project size should be the same whether you implement it in a terse language or in an imperative one, but again, maybe I didn't understand the COCOMO model correctly)?

答:
It may result in fewer faulty characters per program, but that is all you can predict. And the COCOMO metric doesn't account for the natural verbosity of different languages, therefore it is meaningless to use it as an argument for one language over another.

No, the question of whether a language promotes better, more error-free code or not can only be solved through rigorously controlled contrastive experiments. Unfortunately there are few really unbiased research studies, and it seems there is always a reason why a non-advocate will reject the findings of an advocate in favor of one particular language.

Perhaps the most convincing argument is real-world use. Granted, there is a lot of inertia, backward-compatibility constraints, willful ignorance etc. in the world of commercial software development, but you have to ask yourself: if Wonder Language X (be it J, or Lisp, or Haskell, or whatever) really consistently produced better programs faster - wouldn't at least some of the less backward managers eventually notice that and at least try to gain an edge over the competition by using it? And note that it has to bring actual benefits, not benefits that only work for academic toy problem sizes, or only if you have extremely smart people use it.


问:
Make a big deal out of == true?
There is a colleague of mine who constantly writes:

```<code>if (someBool == true)
</code>```

It drives me up the wall!  Should I make a big deal of it or just drop it?

答: I think that, if something so trivial is your biggest problem with your co-workers, you should consider yourself pretty lucky.</p>

ContentLicense: CC BY-SA 2.5

Title: Make a big deal out of == true?


问:
Why do people suggest not to use instance variable for views in Ruby on Rails
Why do I hear that it is not good to share instance variables between controllers and views.  I kind of like it because I can see immediately via the @ that something is coming from the controller.  I see a nice way to use helpers in controllers here: http://www.stephencelis.com/2008/09/06/rails-controllers-views-and-variables.html. But I am using cancan for that portion.</p>

答:
The idea was put up in rails best practices: Replace instance variable with local variable

Basically if you don't use many partials or have a single plain view for each controller method just using the instance variables in the view wouldn't really cause any trouble.

Nevertheless, if you use many partials and therefore have many instance variables declared in your controller..., it might be less confusing if you use the alternative of passing the controller (instance)-variable to the partials explicitly. That way - while working in the partial VIEW - you have one explicit reference to the variable/object you want to work with that is not shared with 'all' partials that are included in the creation of the page.

After all, you can handle this just as you like to handle it, noone will tell you to do it otherwise. My personal view, however, is that I like the idea of having explicitly references in my partials/views that can not be confused with other variables.


问:
Organizing Class Members in Regards to Access Modifier
If we look at typical implementation of a Class, we usually see the private members defined at the beginning and public( mostly functions and Accessors) defined towards the bottom. Now, is this a Industry standard agreed by a lot of people?

How about keeping the private members towards the end as updates and additions are usually done to the Public Members(mostly functions), to fix bug or provide enhancement, so we don't have to scroll down towards the end to get to the function definition section.

I understand, good IDEs will allow us to Jump towards a specific attribute, but considering other factors, such as Code Review, it may be convenient to have the Public Definitions towards the beginning.

What is the most accepted standard for Class Member Organization?

答:
so we don't have to scroll down towards the end to get to the function definition section

If you have so many private members in a class that you need to scroll down far, you might want to look at the design of the class. I don't think you'll find that the biggest problem is whether you placed the private members at the top or the bottom.

Or, to put it another way, if the sequence of definitions in your classes is really the biggest problem you have to solve then congratulations, you have a great code-base, and you should just get on and develop business functionality, rather than worrying about these kinds of details (which, as you point out yourself, your IDE worries about for you).

That said, if your private members are simply backing members for public properties then the simple answer, in later versions of C#, is auto-properties -- but if you need them then they're probably better hidden away at the bottom.

If you are using them to encapsulate abstract services, then I would prefer to see them at the top so that I know, as soon as I enter that class, what kind of dependencies it has.


答: I put public methods at the top of my Class since public methods are the only entry points into encapsulated Class logic.</p>

Title: Organizing Class Members in Regards to Access Modifier

Body:
If we look at typical implementation of a Class, we usually see the private members defined at the beginning and public( mostly functions and Accessors) defined towards the bottom. Now, is this a Industry standard agreed by a lot of people?

How about keeping the private members towards the end as updates and additions are usually done to the Public Members(mostly functions), to fix bug or provide enhancement, so we don't have to scroll down towards the end to get to the function definition section.

I understand, good IDEs will allow us to Jump towards a specific attribute, but considering other factors, such as Code Review, it may be convenient to have the Public Definitions towards the beginning.

What is the most accepted standard for Class Member Organization?


问:
Years experience over unfinished degree?
I'm currently in my placement year and working for a great software development company. It was always my intention of getting to this stage through university, getting enough academic experience as well as the year’s placement and then try to get a full time programming job without the need to finish my degree. I decided this from an early stage as I have never really liked the whole university environment. I was so unhappy at university and I’m so happy now I’m on my placement year, I really don’t know if I can go back.

My question is, do you think companies will take me on if I apply for other jobs after my placement year and not penalize me for not finishing my degree?

I guess at the end of the day I don't want to look back on my life and think "god, why didn't I just spend one more year being unhappy to have a job I love" but I know that even if I get a degree I could still end up without a programming job and this worries me more than anything.

答:
Every company and every hiring manager is different. Some will value hands-on experience more than a degree, but many will not look past the lack of a degree, especially in large companies where hiring is done by a HR department.

Basically lack of a degree:

will be seen neutral to slightly positive in most small startups

will matter little when you get a job via personal recommendation

will get your resume thrown out at a very early stage when applying through the regular channels at most large companies (and many smaller ones)

Overall, I'd say it's a considerable (but not unsurmountable) obstacle to getting a job.


答:
It's probable that you will be able to get a job. It's possible you will even get a good one. I've done all right and I know for a fact that I'm not unique in that.

But you will be penalised. Make no mistake about that. It took me a lonnnnng time (upwards of 10 years) to get up to a rate of pay equal to peers with similar skill-sets. And, even now, I expect that if all other things are equal, I would be rejected in favour of someone with a degree.

Luckily, it's rare that all other things are equal.

But think about it this way: you may have to do some pretty miserable jobs to get to where you want to be. Would it not be easier to put up with a miserable year or so back at university and have the world at your feet at the end of it?

Title: Years experience over unfinished degree?

Body:
I'm currently in my placement year and working for a great software development company. It was always my intention of getting to this stage through university, getting enough academic experience as well as the year’s placement and then try to get a full time programming job without the need to finish my degree. I decided this from an early stage as I have never really liked the whole university environment. I was so unhappy at university and I’m so happy now I’m on my placement year, I really don’t know if I can go back.

My question is, do you think companies will take me on if I apply for other jobs after my placement year and not penalize me for not finishing my degree?

I guess at the end of the day I don't want to look back on my life and think "god, why didn't I just spend one more year being unhappy to have a job I love" but I know that even if I get a degree I could still end up without a programming job and this worries me more than anything.


答: Your lack of degree is a constant recurring issue, every time you change jobs, either because you don't like your current job or because of layoffs, you'll have to overcome your disadvantage. There was a recent question by someone that had a similar question, the main recommendation was to suck it up and finish your degree. I was also glad to start working, but I remember college life wasn't that bad (quite a bit a spare time, flexible hours), although I graduated in the Dutch system, which might differ from the US.  In addition, I became a scientist, so I might have a bias towards an academic environment :).</p>


问:
Which recorder do I use for Selenium 2
We have a web application that we want to start running regression tests on, and have pretty much decided that we will be using Selenium 2. Not all of the testers are programmer savvy. Is Selenium IDE usable for this? Which other recorder alternatives are best for Selenium 2?</p>

答:
Not all of the testers are programmer savvy.

Teach them. Or, if some are bright enough and others not, separate them out into automated testing and support (mostly replicating problems that others have found).

This might sound like an onerous task, but it's really not that hard. They don't need to know about hard-core programming to write tests, simply teach them some Java (or whatever the tests are to be written in) and the PageObject pattern. That's it. If they can't handle the PageObjects themselves then get the programmers to write those while the testers write the tests on top of them.

I strongly recommend against using recorders. Unless you have no javascript whatsoever, you are going to run into problems that need tweaking and the testers will eventually either need to learn simple programming or rely on programmers' help forever.

Better to teach them early and have a good solid test framework for them to work within.

Title: Which recorder do I use for Selenium 2


问:
What are the advantages/disadvantages of using record and playback for regression testing?
We have a web application that we want to start running regression tests on, and one of the things I'm supposed to look for when choosing an alternative is a tool that has a recorder. However, I get the general feeling that it is frowned upon, and that writing tests in code is preferred. What are the eventual disadvantages or advantages of using a record and playback tool for regression testing?</p>

答:
I would not recommend record and play for regression testing for following reasons

The tests would record un-necessary steps depending upon the level of recording present in tool.
e.g In some applications selecting a combobox would be recorded as clicking it first and then selecting it. Sometimes it might be desirable sometimes not.

The objects might get duplicated and unorganized making the test very difficult to maintain.

Anyway to implement the logic and iterations you need to come down to code.

You know what you are doing exactly when hand-coding the test.

I would say its like hand coding a website even though you have a WYSIWYG editor at your disposal. For learning and beginning with a tool and see its constructs you can use record and play but to make stable, maintainable and standard based tests you should hand code it taking help of record functionality if required.

The advantages would be

Easy for beginners. Takes less time to get started.

Faster test development (though eventually maintenance and debugging time would over-weigh this advantage)

Cool to demo to your manager to persuade him to buy the licenses. :)


答:
No, IDE is to help in creating tests not to create tests. You will need to code the tests if you want them to be usable and stable.
As already suggested make the testers learn the tool. No need to learn hard core programmeing, basic Java would suffice.</p>

Title: Which recorder do I use for Selenium 2

Body: We have a web application that we want to start running regression tests on, and have pretty much decided that we will be using Selenium 2. Not all of the testers are programmer savvy. Is Selenium IDE usable for this? Which other recorder alternatives are best for Selenium 2?</p>


问:
Linking Libraries in iOS?
This is probably a totally noob question but I have missing links in my mind when thinking about linking libraries in iOS. I usually just add a new library that's been cross compiled and set the build and linker paths without really know what I'm doing. I'm hoping someone can help me fill in some gaps.

Let's take the OpenCV library for instance. I have this totally working btw because of a really well written tutorial( http://niw.at/articles/2009/03/14/using-opencv-on-iphone/en ), but I'm just wanting to know what is exactly going on.

What I'm thinking is happening is that when I build OpenCV for iOS is that your creating object code that gets placed in the .a files. This object code is just the implementation files( .m ) compiled. One reason you would want to do this is to make it hard to see the source code and so that you don't have to compile that source code every time.

The .h files won't be put in the library ( .a ). You include the .h in your source files and these header files communicate with the object code library ( .a ) in some way.

You also have to include the header files for your library in the Build Path and the Library itself in the Linker Path.

So, is the way I view linking libraries correct? If , not can someone correct me on this ?

答:
The way you see the linking process is correct.

Producing a library eases :
- source code protection
- distribution
- compile time

The process you describe is exactly the same for C, C++

You mention only static libraries but the process is similar for dynamic libraries.

Title: Linking Libraries in iOS?


答:
I think that the practice of declaring privates first and publics afterwards has been inherited from C. What usually happens is that publics refer to privates, but not the other way around, so you could not declare your publics first without using lots of highly inconvenient forward references. So, there is a long tradition of doing that, and people are used to it.

Of course, with modern languages like C# there is no reason for doing this any more.

That having been said, I feel compelled to add that I do not happen to be particularly fond of tradition.


答:
Is the COCOMO model a good argument when defending a programming language choice?

No. COCOMO says nothing about language choice at all. It is a cost estimation tool to determine how much it will cost to build a given software system given a series of inputs. The latest iteration is COCOMO II, and there are web based tools to use when applying this model. Some of the inputs that go into COCOMO II include the estimated size in SLOC or function points, the team cohesion, maturity of the process, desired reliability, complexity, the capability of people filling different roles on the team, platform constraints, and schedule. The output is the estimate for effort, schedule, and cost for the project.

Only a handful of the inputs are related to technology and programming language. The key adjustment factors that cover these areas are the capabilities of the programmer, experience of the programmer in the application domain, experience with the platform and language, and the ability to obtain and use supporting tools.

As far as defending a language, the best that you can do with COCOMO is produce multiple estimates for different technologies and languages that the team knows to varying degrees. Perhaps there's one technology that the entire team knows and has successfully used before, so platform and language experience would be high, but that language has very few supporting tools so that would be lower. You can compare that to a language that perhaps only one person knows extremely well and a few people know a little about, calling the experience nominal, yet factoring in the rich tool set. Given two (or more) sets of effort, schedule, and cost estimates, you can compare to see which might be more effective to use.

Also, since the language is terse, the number of lines of code is reduced and you would get a better COCOMO rating.

There is no such thing as a COCOMO rating. COCOMO is an estimation tool that you can use to try to determine how much effort (person-months), schedule (months), and cost a project will require to complete. When estimating, this data is compared against the size of the project team and the business schedule to determine if it's realistic and to provide the project manager with information needed to control the project schedule.

For example, COCOMO might produce a schedule estimate of 15 months and a cost estimate of $500,000. However, the business schedule might call for 12 months and $450,000. This schedule and isn't unreasonable, and the project manager can use this information when controlling the project and negotiating with the customer.

But can this be applied in the first place or does the COCOMO model use the number of lines of code as a way to estimate a project's overall size (project size should be the same whether you implement it in a terse language or in an imperative one, but again, maybe I didn't understand the COCOMO model correctly)?

Although source lines of code (SLOC) is a valid input to COCOMO, estimating size using source lines of code is not recommended because the number of SLOC varies depending on programming language (among a number of other problems). Function points are a preferred method of size estimation. There are conversion ratios that allow you to estimate a number of function points and apply the ratio to determine the size of the system in a given programming language.

Now, comes the other parts to your question.

Currently, I'm following a course on embedded software development. The lecturer has chosen J as an architecture language for model-driven software development. J itself is a very terse programming language and one of his main arguments for this language is its terseness. Another argument is that through such a language and the reduced number of characters, you introduce less bugs and the time to fix bugs is reduced. [...] I feel that these arguments aren't valid. I find that there is a strong movement towards descriptive names and code that reads like natural language (alright, this might only be related to applications with lots of business logic and less math).

That's nice. In my experiences, the lecturer has more experience in the topic than the typical student. When they choose a given language, framework, platform, or technology to use to teach their content, they have a good reason to.

Terseness is, in my opinion, a rather poor measure to discuss a language on. There are far better criteria to use when choosing a language to implement a project in - platform support, tool support, available resources, team knowledge. With never having seen J before, it seems rather difficult to read. However, it might be very good at solving the particular problems that the project is trying to solve, and the people on the team might have experience with it. It might also be easy to learn.

In your specific case, of a class, you need to focus on the point - learning concepts and techniques. Not only will you learn about J (and learning new tools is always good), but you'll learn techniques that can probably be applied to other languages as well.

The question therefore is, can you really argue that usage of a terse programming language will result in less errors and that time to fix a bug is reduced?

My intuition says no, but that's beside the point. You need to factor in knowledge of the language, supporting tools (compilers, IDEs, static analysis), and process methodology (pair programming, code reviews, style guidelines), and more to have an adequate discussion of how to reduce errors and time-to-fix.

If you're interested in more about COCOMO and what it's all about, I'd recommend reading Software Engineering Economics and Software Cost Estimation with COCOMO II, both by Barry Boehm. Software Engineering Economics is mostly general software project management, cost estimation, and effort estimation. The portion of the book that discusses COCOMO discuses the COCOMO 89 version, which Boehm has said should no longer be used due to inaccuracies that were corrected in the COCOMO II version, however the rest of the sections of the book are still relevant.

Body:
Currently, I'm following a course on embedded software development. The lecturer has chosen J as an architecture language for model-driven software development. J itself is a very terse programming language and one of his main arguments for this language is its terseness. For instance, this is a Quicksoft implementation in J:

```<code>quicksort=: (($:@(<#[) , (=#[) , $:@(>#[)) ({~ ?@#)) ^: (1<#)
</code>```

Another argument is that through such a language and the reduced number of characters, you introduce less bugs and the time to fix bugs is reduced.

Since I have a strong software engineering background and through various books like Clean Code, Pragmatic Programmer and others, I feel that these arguments aren't valid. I find that there is a strong movement towards descriptive names and code that reads like natural language (alright, this might only be related to applications with lots of business logic and less math).

The question therefore is, can you really argue that usage of a terse programming language will result in less errors and that time to fix a bug is reduced? Also, since the language is terse, the number of lines of code is reduced and you would get a better COCOMO rating. But can this be applied in the first place or does the COCOMO model use the number of lines of code as a way to estimate a project's overall size (project size should be the same whether you implement it in a terse language or in an imperative one, but again, maybe I didn't understand the COCOMO model correctly)?


答:
When I see someBool == true, I can't help but feel like the programmer hasn't internalized the idea of evaluation, which is a pretty fundamental deficiency.

However, my perspective is skewed because I spent several summers in college teaching programming to kids, who frequently wrote expressions like this because they genuinely hadn't mastered the mental exercise of evaluating an expression.  Once they grokked the concept, the redundancy became obvious.

For an otherwise competent professional programmer, this is probably not the case.  It's probably just a bad habit they developed in their early days of programming and never quite shook.  But it would still scare me a bit if it was the first thing I saw someone do in an interview.

Title: Make a big deal out of == true?

Body:
There is a colleague of mine who constantly writes:

```<code>if (someBool == true)
</code>```

It drives me up the wall!  Should I make a big deal of it or just drop it?


答:
First.  Do you want to pass the course?  If so, learn J rather than argue with the lecturer.  Learning J has value.

Second.  COCOMO backs up the lecturer, not you.

can you really argue that usage of a terse programming language will result in less errors and that time to fix a bug is reduced?

Yes.  That's what COCOMO says.  Lines of code ➜ effort ➜ duration (and staffing and cost).

since the language is terse, the number of lines of code is reduced and you would get a better COCOMO rating.

Correct.

But can this be applied in the first place

What?

or does the COCOMO model use the number of lines of code as a way to estimate a project's overall size (project size should be the same whether you implement it in a terse language or in an imperative one,

No.

maybe I didn't understand the COCOMO model correctly)?

You did.  CoCoMo says lines of code == effort, and J will minimize lines of code.

Third.  J has value even if you initially find it unclear.

A predecessor to J, APL, was invented specifically to mirror mathematical notions of reasoning, the way operators work across various data types and the way functions can be combined in a functional programming sense.

The point of APL (and J) is to allow you to create new, higher-order, application-specific operators so that your code looks (and feels) like ordinary mathematics.  It reduces the "gap" between specification, design and implementation.

Title: Is the COCOMO model a good argument when defending a programming language choice?


答:
In addition to what others have said about the lack of a degree being a recurring issue every time you go looking for a job, which at best is a factor that doesn't work to your disadvantage, I would also question your thought about "years experience", particularly starting out.

I'm not involved in hiring decisions, but if I was faced between the choice of one candidate who is a college/university dropout with maybe 1-2 years of experience, and another who completed higher education and has the same amount of experience, all else being equal (which of course it never is) I would probably pick the latter because, knowledge aside, it also shows an ability to finish what you start on.

Now, it is of course possible that you have some other quality that will work in your favor and which might even outweigh the fact that you dropped out of college/university, but you will still have to get past the requirement for a degree every time you apply for a job, particularly if you don't have a personal recommendation. This can be a major hurdle, particularly early on in one's career before one has gained a lot of real-world work experience and built a large network of professional peers.


问:
C++ for C# Developers
I know C# pretty well (self-taught, sadly) and need to do some C++ programming for a Windows application.  I have been able to find a ton of information for C++ developers learning C# but haven't been able to find much on learning C++ when you already know C#.  Has anyone come across a good rundown of the basics?

MSDN has a comparison but it is not very in-depth.

I can piece together several sources but figured something was out there - I just can't find it.  Thanks for your help.

答:
Look out for memory management. Get clear idea on how pointers and references work in C++ in contrast to C#. Also, RAII, manual memory management and smart pointers at last.

Templates and generics looks similar but are different beasts. Know the internals of how templates work.

There are some tiny but catchy syntactic differences. Learn them.

You have get used to STL instead of .net BCL. You may going to miss some good bits if have LINQ addiction.

There are some fundamental design difference between C++ and C#. So, you cannot just port an idea. Anything you build with C++, you have to design from scratch.

Goodluck

Title: C++ for C# Developers


问:
How to store exception messages
How are exception messages commonly stored? for any domain. I'm thinking about this from a maintenance standpoint.

```<code>if(!Condition1)
    throw new Exception("Some exception");

if(!Condition2)
    throw new Exception("Some exception");
</code>```

If it was decided that the exception message in that snippet needed to be changed, it would have to be changed in two places; leaving it wide open for inconsistent messages and such.

How better to store exception messages then? Perhaps as a static class with constants?

```<code>public static Exceptions
{
    public const string CONDITION_NOT_MET = "Some exception";
}
...
if(!Condition1)
    throw new Exception(Exceptions.CONDITION_NOT_MET);

if(!Condition2)
    throw new Exception(Exceptions.CONDITION_NOT_MET);
</code>```

Are they often (in production) hardcoded?

答:
In my opinion the constructor of Exception should not be accepting a string message parameter, nor any other kind of identifier that stands for the message. The message is the name of the type of the exception.

In my projects for convenience I make use of an exception that I call GenericException which accepts a string message, but the intent is to replace it with a specific exception type, created especially for that purpose, before deployment, ideally before source code commit.

What you can do is have a dictionary in which the key is an exception type and the value is the corresponding message. You can also use formatting in the message, and use reflection to fetch values of members of the exception, and pass them to the String.Format function, so as to make your messages richer.

So, in your case you should define a ConditionNotMetException, derived from System.Exception. If you have no other information to pass in it, then leave it as an empty class. Alternatively, you may want to include some members in it, containing additional information about the condition which was not met, why it was not met, etc.

However, these members should be just raw values, they should not be processed into string messages by the exception. For example, if you had an exception called DateOutOfRangeException you may want to include in it 3 DateTime fields: one for the date that was found to be out of range, and another two defining the range. Then, it is the responsibility of the application to present the user with a meaningful message containing these three dates.

Title: How to store exception messages


答:
Reading this question and some of the answers it has received prompted me to write an article which I feel might be of interest:

Odd recruitment practices when hiring software developers

Ok, so the article title is rubbish, but the article gets to the heart of the problem.  It's not the candidate's problem that you've chosen to interview them no matter how inappropriate they may be for the role you have in mind.  If you haven't managed to define a well-factored hiring procedure to allow you to find the gems in the rough, then you're going to just have to live with the consequences, and yes, this means getting a few candidates that could never meet with your expectations.  Filtering your candidates based on their letters and resumes requires you to first, ask your applicants to write a letter about themselves and what they want from the role, and then look at how the resume is written.  If you've only got one or two potential candidates to interview, then you've probably done the pre-screening properly. If you can't decide between your candidates at this stage and you still have a hundred applications, then you've probably either set your expectations too low, or you haven't been aggressive enough in your filtering process.

When you eventually do find the 1 or 2 candidates that you consider actually worth your time, don't simply ask a handful of inane tester questions, but instead invest the time to get to know these people, and to engage in open discussions about software engineering in general.  You'll learn more from a casual approach about the candidate than you ever will in the traditional (and somewhat adversarial) interview situation.  Also, don't simply settle for a single interview, but instead treat your key candidates to several meetings where open discussion is used, and where the candidate can meet with their prospective colleagues.  The time is never wasted, as inappropriate candidates will not thrive very well in a highly technical discussion, and will show their flaws very quickly as they drop their guard.  If you spend the time and still don't have a hire, you've had an opportunity to learn more about what your needs are, and can continue to improve your interviewing process based on what you learned from the 'failed' interviews.

Title: What is the best way to evaluate new programmers?

Body:
What is the best way to evaluate the best candidates to get a new job (talking merely in terms of programming skills)?  In my company we have had a lot of bad experiences with people who have good grades but do not have real programming skills.  Their skills are merely like code monkeys, without the ability to analyze the problems and find solutions.

More things that I have to note:

The education system in my country sucks--really sucks.  The
people that are good in this kind of job are good because they have talent for it
or really try to learn on their own.

The university / graduate /post-grad degree doesn't mean necessarily that you know exactly how to do the things.

Certifications also mean nothing here because the people in charge of the certification course also don't have skills (or are in low paying jobs).

We need really to get the good candidates that are flexible and don't have mechanical thinking (because this type of people by experience have a low performance).

We are in a government institution and the people that are candidates don't necessarily come from outside, but we have the possibility to accept or not any candidates until we find the correct one.


问:
Keeping a connection string secure when working with others
Say you've started an open source project and are posting it on a public repository.  (like I have, using Codeplex.)

One of the key files just makes the connection to the database, contains the login/password, and is just included from any other source file that needs a database connection.

What's the best way to share the project without giving out your password?

So far I've specifically removed it before committing any changes, but I'm thinking there has to be a better way.

答:
One trick learned in the ASP classic days, was to have the connection string in an outside file.

```<code>''// Init the ADO objects  & the stored proc parameters
cmd.ActiveConnection = "file name=c:\udl\mydb.udl"
cmd.CommandText = sqlstmt
cmd.CommandType = adCmdStoredProc
....
</code>```

It works in ADO, don't know your environment

Body:
One trick learned in the ASP classic days, was to have the connection string in an outside file.

''// Init the ADO objects  & the stored proc parameters
cmd.ActiveConnection = "file name=c:\udl\mydb.udl"
cmd.CommandText = sqlstmt
cmd.CommandType = adCmdStoredProc
....

It works in ADO, don't know your environment


问:
what is exactly an enterprise app store
My idea of an enterprise app store is that there is a page on the company's website where all the apps that that company developed for its employees are listed so they can use them. And access to this apps is restriceted to the employees of the company.

As far as I know you can download an Android App from any website and install it on an Andoid phone, you don't have to use Android Market. However installing an App that does not come from the Android Market is not that straightforward.

For Apple, you can only install an app from the Appstore, so how can you have an enterprise app store?

Please tell me what exactly is an enterprise app store. I think I got it wrong, also I read a lot on the internet for this keywords.

答:
For Apple, you can only install an app from the Appstore, so how can you have an enterprise app store?

http://embarcadero.com/appwave/images/AppWave-OVUM-WP.pdf

This reference uses a rhetorical technique called "reasoning by analogy".  They're not saying that an enterprise must literally run the exact Apple-branded App-Store web site in some kind of magical "internal mode" that doesn't appear exist.

They're suggesting that the app store model might be a good idea for an enterprise to find a way to adopt.

There's a world of difference between "app store" and "Apple's App Store".  One is a broad, vague, good idea.  An enterprise could use this Design Pattern and build something good for their users.

The other is a specific piece of software that an enterprise can't easily run internally.

Title: what is exactly an enterprise app store


答: The thing about a college degree in the US is that it's the only legal way companies and government agencies have to determine and compare an applicant's general intelligence. That's why having a degree serves as a gate keeping function at many companies. Some companies take it even further and look for specific degrees from specific universities, believing that this will provide them with the best and brightest employees. </p>


答:
I will chime in with what @MikeNakis says: the exception type used should be fine-grained enough that you can discern to some reasonable degree what the problem was from looking only at that and possibly the stack trace. If the intent was that one should just throw Exceptions around, then that type would have been made final, sealed or whatever happens to be the term in one's programming language of choice, but that is not the case in any language or framework I know of. In fact, catching Exception is often frowned upon, as it is a cop-out that is very likely to hide real, serious problems.

The exception message should be used to provide details that cannot reasonably be expressed through the type system.

Your second example is actually worse, IMO: you are replacing hard-and-fast types with string literals that are bound to become out of date, misused, changed in ways not expected in some parts of the code, or in any number of other possible ways inaccurate. And in ways that the compiler doesn't have a glimmer of hope of helping you catch, in any language.

Exception messages should not need to be changed. To the extent that they are to be used at all (which should be sparingly, IMO; see previous discussion), they should be meant for programmers (and possibly power users, who can enable display of the messages through some mechanism), not end users. Thus, the exact phrasing becomes less important than the fact that the message clearly describes the conditions that caused the exception but which cannot be adequately expressed through the type system.

Also, unless you really need free-form text messages with no built-in semantics as exception clarifiers (unlikely), you are almost always better off forgetting entirely about building and passing a single string message. Let's say you have a piece of code that requires that a certain variable is within a given range, and must throw an exception otherwise. Instead of (pseudo-C#/.NET; I know you could use string building features like StringBuilder or String.Format, but that's not the point here):

```<code>if (x < 3 || x > 10)
    throw new VeryGeneralException("Got " + x.ToString() + " wanted min 3 max 10");
</code>```

you might do something like:

```<code>public class OutOfRangeException : Exception
{
    public int Value { get; private set; }
    public int MinValue { get; private set; }
    public int MaxValue { get; private set; }

    public OutOfRangeException(int value, int minvalue, int maxvalue)
    {
        base("Got " + value.ToString() +
             " wanted min " + minvalue.ToString() + " max " + maxvalue.ToString());
        this.Value = value;
        this.MinValue = minvalue;
        this.MaxValue = maxvalue;
    }
}
... then far later ...
if (x < 3 || x > 10)
    throw new OutOfRangeException(value: x, minvalue: 3, maxvalue: 10);
</code>```

That way:

by looking at only the exception type name, you know that some value was out of its allowed range

with the resulting generated message, you know the value of the variable in question and its expected range

along with the full stack trace, you have a pretty decent idea how you got to that point (which, depending on the architecture and the semantics of the value in question, may or may not help you determine why the value was out of its allowed range)

This way, a single exception, including its stack trace, gives you about as much detail as you can hope to get short of a step-by-step description of how to repeat the error.

Title: How to store exception messages

Body:
How are exception messages commonly stored? for any domain. I'm thinking about this from a maintenance standpoint.

```<code>if(!Condition1)
    throw new Exception("Some exception");

if(!Condition2)
    throw new Exception("Some exception");
</code>```

If it was decided that the exception message in that snippet needed to be changed, it would have to be changed in two places; leaving it wide open for inconsistent messages and such.

How better to store exception messages then? Perhaps as a static class with constants?

```<code>public static Exceptions
{
    public const string CONDITION_NOT_MET = "Some exception";
}
...
if(!Condition1)
    throw new Exception(Exceptions.CONDITION_NOT_MET);

if(!Condition2)
    throw new Exception(Exceptions.CONDITION_NOT_MET);
</code>```

Are they often (in production) hardcoded?

Body:
I will chime in with what @MikeNakis says: the exception type used should be fine-grained enough that you can discern to some reasonable degree what the problem was from looking only at that and possibly the stack trace. If the intent was that one should just throw Exceptions around, then that type would have been made final, sealed or whatever happens to be the term in one's programming language of choice, but that is not the case in any language or framework I know of. In fact, catching Exception is often frowned upon, as it is a cop-out that is very likely to hide real, serious problems.

The exception message should be used to provide details that cannot reasonably be expressed through the type system.

Your second example is actually worse, IMO: you are replacing hard-and-fast types with string literals that are bound to become out of date, misused, changed in ways not expected in some parts of the code, or in any number of other possible ways inaccurate. And in ways that the compiler doesn't have a glimmer of hope of helping you catch, in any language.

Exception messages should not need to be changed. To the extent that they are to be used at all (which should be sparingly, IMO; see previous discussion), they should be meant for programmers (and possibly power users, who can enable display of the messages through some mechanism), not end users. Thus, the exact phrasing becomes less important than the fact that the message clearly describes the conditions that caused the exception but which cannot be adequately expressed through the type system.

Also, unless you really need free-form text messages with no built-in semantics as exception clarifiers (unlikely), you are almost always better off forgetting entirely about building and passing a single string message. Let's say you have a piece of code that requires that a certain variable is within a given range, and must throw an exception otherwise. Instead of (pseudo-C#/.NET; I know you could use string building features like StringBuilder or String.Format, but that's not the point here):

if (x < 3 || x > 10)
    throw new VeryGeneralException("Got " + x.ToString() + " wanted min 3 max 10");

you might do something like:

public class OutOfRangeException : Exception
{
    public int Value { get; private set; }
    public int MinValue { get; private set; }
    public int MaxValue { get; private set; }

    public OutOfRangeException(int value, int minvalue, int maxvalue)
    {
        base("Got " + value.ToString() +
             " wanted min " + minvalue.ToString() + " max " + maxvalue.ToString());
        this.Value = value;
        this.MinValue = minvalue;
        this.MaxValue = maxvalue;
    }
}
... then far later ...
if (x < 3 || x > 10)
    throw new OutOfRangeException(value: x, minvalue: 3, maxvalue: 10);

That way:

by looking at only the exception type name, you know that some value was out of its allowed range

with the resulting generated message, you know the value of the variable in question and its expected range

along with the full stack trace, you have a pretty decent idea how you got to that point (which, depending on the architecture and the semantics of the value in question, may or may not help you determine why the value was out of its allowed range)

This way, a single exception, including its stack trace, gives you about as much detail as you can hope to get short of a step-by-step description of how to repeat the error.


答:
Let the message be telling.  A good thing to tell is what went wrong:

if(!Condition1)
      throw new Exception("!Condition1");

if(!Condition2)
      throw new Exception("!Condition2");

The more complex the expression in the if the more information you will need to avoid a debug step.  For instance

if ((x>10) || (y<0))
     throw new RuntimeException("(x>10) || (y<0), x="+x+",y="+y);

This will allow the maintenance engineer to analyze the error without having to run the program again.  Some day you will appreciate this

Title: How to store exception messages


答:
My idea of an enterprise app store is that there is a page on the company's website where all the apps that that company developed for its employees are listed so they can use them. And access to this apps is restriceted to the employees of the company.

Correct. The idea is that as a company you provide common and useful apps to allow your staff to do their work/get information no matter where they are. The apps might provide report data, current sales(per minute/hour), sale targets or even network availability server status.

For Apple, you can only install an app from the Appstore, so how can you have an enterprise app store?

While a bit dangerous You develop your app as normal and publish to the Apple Appstore. When a user tries to use it they have to enter a registration key which is only provided to approved users and is unique to each user.

Personally I have mixed views on the concept of an App Store. You would hope that in most organisations that there is already a defined list of applications provided that allows everyone to do their work. If there isn't then providing an App Store won't help as the apps still need to be written and if they haven't been written before now I can't see the enterprise investing in an App store.

Title: what is exactly an enterprise app store

Body:
My idea of an enterprise app store is that there is a page on the company's website where all the apps that that company developed for its employees are listed so they can use them. And access to this apps is restriceted to the employees of the company.

As far as I know you can download an Android App from any website and install it on an Andoid phone, you don't have to use Android Market. However installing an App that does not come from the Android Market is not that straightforward.

For Apple, you can only install an app from the Appstore, so how can you have an enterprise app store?

Please tell me what exactly is an enterprise app store. I think I got it wrong, also I read a lot on the internet for this keywords.


问:
Programming around email address case sensitivity
Like many websites, we use email addresses as user identifiers for logins.

RFC 5321 [#2.3.11] states that the local parts of email addresses:

MUST be
interpreted and assigned semantics only by the host specified in the
domain part of the address

This means that applications processing email addresses can't second guess, for example, the way that GMail will ignore dots when determining usernames. It also means that applications must treat email address local-parts as case sensitive, since that's how the local part is specified.

However users are stupid, and in a recent case a user who had signed up with an uppercase email address (and had successfully received and clicked the verification email) found they were unable to log in because they were now using the lowercase format of their email address.

I've never come across an email server which enforced case-sensitivity on its inboxes. I don't doubt that some exist somewhere, but I'm questioning whether there isn't a bigger benefit to dropping case-sensitivity for our email usernames than there are problems keeping it.

I wouldn't go so far as to emulate GMail's dot processing, or any kind of plus-addressing, because those don't seem to be as ubiquitous or as automatically-assumed as case-sensitivity. However, I'm aware it's not a black and white scenario so I'm interested if anyone knows how widespread case-sensitive email addresses actually are.

答:
https://www.rfc-editor.org/rfc/rfc5321#page-42 (emphasis added):

While the above definition for Local-part is relatively permissive, for maximum interoperability, a host that expects to receive mail SHOULD avoid defining mailboxes where the Local-part requires (or uses) the Quoted-string form or where the Local-part is case-sensitive.

The rfc discourages case-sensitivity.  Also, I personally have never seen a host with case-sensitive local parts.

Case-insensitive email addresses are a de-facto standard.

Therefore, I think you are correct to say there is bigger benefit to dropping case-sensitivity for your email usernames than there are problems keeping it.


问:
What should I do to scale out a high-traffic website?
What best practices should be undertaken for a website that needs to "scale out" to handle capacity?  This is especially relevant now that people are considering the cloud, but may be missing out on the fundamentals.

I'm interested in hearing about anything you consider a best practice from development-level tasks, to infrastructure, to management.

答:
Parallelize requests over several hostnames

Part of the HTTP standard is a section that says webclients will request a maximum of 2 sessions per DNS Host.  Here is a solution where you and alias out your www.domain.com and get a higher request concurrency, making your page load faster:

https://stackoverflow.com/questions/3653609/how-do-i-code-my-asp-net-page-to-parallelize-downloads-across-hostnames

Basically it involves editing your ASP.NET HTTP Handler to alternate the target hosts you send clients to, where each host is a CNAME to "www".


答:
It sounds to me like you're sharing your code, but not the connection.

You may want to just store your password in a file outside your checkout or a file that is marked as ignored by your version control. I have a set of scripts at work that need my username/password that I shared, and I just have it look at ~/.live_db to get my info.

Title: Keeping a connection string secure when working with others

Body:
Say you've started an open source project and are posting it on a public repository.  (like I have, using Codeplex.)

One of the key files just makes the connection to the database, contains the login/password, and is just included from any other source file that needs a database connection.

What's the best way to share the project without giving out your password?

So far I've specifically removed it before committing any changes, but I'm thinking there has to be a better way.


答:
Paragraph 2.4. General Syntax Principles and Transaction Model of RFC 5321 states (emphasis mine):

Therefore, SMTP implementations MUST take care to preserve the case of mailbox local-parts. In particular, for some hosts, the user "smith" is different from the user "Smith". However, exploiting the case sensitivity of mailbox local-parts impedes interoperability and is discouraged. Mailbox domains follow normal DNS rules and are hence not case sensitive.

AFAIK all popular mail hosts avoid case sensitive emails, and you should too. I haven't used a service which assumed case sensitivity for emails, and I hate to be surprised.

Title: Programming around email address case sensitivity

Body:
Like many websites, we use email addresses as user identifiers for logins.

RFC 5321 [#2.3.11] states that the local parts of email addresses:

MUST be
interpreted and assigned semantics only by the host specified in the
domain part of the address

This means that applications processing email addresses can't second guess, for example, the way that GMail will ignore dots when determining usernames. It also means that applications must treat email address local-parts as case sensitive, since that's how the local part is specified.

However users are stupid, and in a recent case a user who had signed up with an uppercase email address (and had successfully received and clicked the verification email) found they were unable to log in because they were now using the lowercase format of their email address.

I've never come across an email server which enforced case-sensitivity on its inboxes. I don't doubt that some exist somewhere, but I'm questioning whether there isn't a bigger benefit to dropping case-sensitivity for our email usernames than there are problems keeping it.

I wouldn't go so far as to emulate GMail's dot processing, or any kind of plus-addressing, because those don't seem to be as ubiquitous or as automatically-assumed as case-sensitivity. However, I'm aware it's not a black and white scenario so I'm interested if anyone knows how widespread case-sensitive email addresses actually are.


问:
Is there any way to test how will the site perform under load
I have made an Asp.net MVC website and hosted it on a shared hosting provider. Since my website surrounds a very generic idea, it might have number of concurrent users sometime in future.

So, I was thinking of a way to test my website for on-load performance. Like how will the site perform when 100 or 1000 users are online at the same time and surfing the website. This will also make me understand whether my LINQ queries are well written or not.

答:
You can look into tools like JMeter or The Grinder.

I've only used JMeter so far, it is a graphical tool that lets you build test plans quite easily. You can simulate multiple users with multiple threads. You can also record typical usages of your site by linking your browser with a JMeter proxy and doing the actual work, so you don't need to write the requests from scratch yourself. The Grinder is script-based if I recall correctly, might be a good fit as well.


答:
I started out in Computer Science in 2000 and left after 3 years when my internship offered me a full time job. I was ecstatic that I was making more than I was paying to go to school. Now after being at the job for 8 years now I have gained some valuable work experience but have very little to show for it in terms of financial compensation.

I started looking for jobs two years ago because I wanted a change of pace and just to do some different type of coding. Even though I am making good money I know that I could be doing much better in that department with my years of experience and knowledge. What I found was that it was easy as hell to get a job offer but everybody wanted to low ball me on the money side because, "I didn't have a degree." They wanted to hire me for my experience but they also felt they could get me for cheap because I didn't have that piece of paper.

Experience is valuable to the employer while your degree is valuable to you. Unless you start your own company and it becomes very successful, you will never make as much money as you can working a job without a degree. Plain and simple. I learned this the hard way.

I know it sucks right now but stay in school and finish so you can get that out the way. And if you have time maybe get some experience on the side too. But don't just drop school. Your future employers will hold it against you for no reason.

Also I make decent money without a degree but I am talking six figures possibly with a degree if you play it right.

Hope this helps...


答:
You're on shared hosting so it's unlikely you'll be able to run any tests that are properly indicative of performance, since there's no guarantee of the level of resources your application will have access to at any one time.

However, what I would do in that situation is to start by running a test in isolation on a dedicated box (this can be you own laptop); use a tool like the Visual Studio Load Test suite or JMeter (which I personally can't stand), and build a set of tests that represent a typical path through your application (you should be able to get information about a typical path through use of Google Analytics. If this is not available, you can just use one you think is likely, but remember that this will not give as accurate a baseline). Then do a ramp-up test, start at 1 user, then slowly add users until you hit your estimated peak load. That should show you how well your system holds up as a whole (I personally like to take it a bit further to make sure I've got some headroom).

The final thing you'll want to do is run a profiling tool like ANTS performance profiler while running the test (be aware that this adds some overhead). This will allow you to identify long-running queries and methods, giving you pointers as to where your application is really slow (one tip: it's almost never actually where you think it will be).

The main issue you will have is, as I said first, that you are on shared hosting, so it will be nigh-on impossible to get do any realistic live-environment emulation. However, if your application has a decent amount of headroom on a similar environment to your promised resources you should have some confidence that the code can hold up in your hosting, even if you hit the limits of your environment before you expect to.

Title: Is there any way to test how will the site perform under load

Body:
I have made an Asp.net MVC website and hosted it on a shared hosting provider. Since my website surrounds a very generic idea, it might have number of concurrent users sometime in future.

So, I was thinking of a way to test my website for on-load performance. Like how will the site perform when 100 or 1000 users are online at the same time and surfing the website. This will also make me understand whether my LINQ queries are well written or not.


答:
Not having a degree can definitively close doors to full time positions at some of the larger companies as they can write their internal standards in such a way that having the degree is a condition of employment. There are some ways around this such as being actively matriculated into a program (depends on the company and how much they want you) or by just working for them as a contractor (although you might not get paid as much as someone with the same experience as you and a degree), but you will find doors that are closed and in some cases you will not know about it unless someone tells you. Likewise, HR departments typically use keyword filtering on CVs that are submitted and might discard yours if it doesn't mention having a Bachelors or at least an Associates degree.

That said though, it does depend upon what you want to do as consultant and contract jobs typically don't care if you have the degree as long as you can do the work that they need you to do. The catch is that you need to keep up with what is the most likely skill set to get you hired.

Also, as others have pointed out, smaller start-ups either don't care, or could see the lack of a degree as a plus as long as you have a strong portfolio of code demonstrating that you know what you claim to know. If you enjoy that type of work you may be good to go already.

Finally, if you want to do some sort of work for yourself (i.e. writing programs for the various app markets) then there really aren't any education requirements beyond being able to learn what you need to learn. The catch is that income could take awhile to build up to where you would be if you were working for a company and you taxes are going take up more of your time.


问:
communication, realistic approach
I work for a mid sized Architecture and Engineering firm, our sub group focuses on developing tech solutions for engineers, mappers and technical managers. So we're heavy on desktop based apps for GIS and Civil/Env Engineering (some web). The company sells the services that our Engineers and mappers produce and our team develops tools that aids in them being more productive, efficient and help in adding value to their decisions and products, we DO NOT sell the technology.

We are going through growing pains where initially we used to be extremely responsive and could rapidly prototype apps for engineers which immediately brought budgetary savings. That mindset has worked for us in the past. But this year we won a huge contract and our client base has basically quintupled (5 times?). What we are finding is that this rapid prototyping culture is hurting us, where project managers have started to expect short response times for tool development and robust production ready tools for all our engineers and GIS analysts. We've grown organically and now it seems that we are running into these issues were it appears we have to scale back our speed for more stability.

Is this a legitimate tradeoff? Is there a win-win? How does one push back the engineer, project manager and analyst when they are our clients, they fund us and yet we need to be able to push back and tell them that if they want stability they have to be realistic about time frames?

This isn't Microsoft Word, these are specialized GIS software and Engineering models with a ton of interop components for other industry standard models, they aren't idiot proof tools, they need informed inputs and we can only test things so much.

Has anyone dealt with similar growing pains? Recommendations/advice on a communication stance, books, blogs?

答:
First of all I think the basic idea of quick development and delivery is fine and if you can keep it then great, do so (it is the gist of the Agile Movement).

Question is why you have problems now?  Is the problem that you cannot deliver as fast because you have more clients to share your time?  Is the problem that the new employees cannot produce new code fast enough?

My personal guess is that you've found that "talent doesn't scale" and that you now have too few experienced programmers to do what you did before for more clients.

EDIT:  If so, you need to acknowledge this fact, as it is impossible to throw additional people at the problem to keep the scaling (Brooks's law).  Your experienced people will need to mentor new apprentices, and that will take some time.

Title: communication, realistic approach


答:
First of all, the proper term is stress test. There are quite a few solutions for website stress tests, one hosted solution I'd recommend is loadimpact. What they do is bombard your site with requests from various servers worldwide and give you an analytic report of how your site handled the stress. They have a free test, where you can get a general idea, but for more you'll have to pay a subscription fee.

These kinds of tests only test the website from the visitors point of view, for more specific information you should profile your application locally, and I don't really have anything more to add to the previous answers, I'm using Apache JMeter as well.

And, lastly, as any performance conscious web developer, you should take a look at YSlow:

YSlow analyzes web page performance by examining all the components on the page, including components dynamically created by using JavaScript. It measures the page's performance and offers suggestions for improvement.

YSlow for Firefox is integrated into the Firebug web development tool for Firefox.

More often than not, I find Javascript to be the actual bottleneck and not back end code or the database. Of course badly written queries can be a major performance penalty, but after you dealt with those, always run YSlow and follow its suggestions, it's a life saver.

Further reading:

Best way to stress test a website

ASP.NET Stress Testing

on StackOverflow, of course!


答:
What you should be doing is using the email address as provided for sending emails and transforming it into something less error-prone when using it as an account identifier or at least using it as a fallback when you don't find an exact match.

This would be a very rough analogue to what the Soundex algorithm does for words or names in English by removing the things that create ambiguities.  For example, you might convert the entire address to lowercase and remove subaddresses and non-alphanumeric symbols from the local part (e.g., Lance.Boyle+sometag@Example.com would strip down to lanceboyle@example.com).  Applying the same transformation to any address used during login would get you a match for more variants, and the user is none the wiser because any other use of the address would be the as-provided version.

From a technical standpoint, this does make your logins marginally easier to brute force.  If that's a concern, you can always require an exact match for logins and provide a "forgot my login or password" option that's tolerant when looking up the account since any email you send will be to the "right" address.

If an address like the one above makes it all the way through sign-up and verification, I don't think it would be unreasonable to reject others that transform the same way as duplicates.  I'd posit that any site that assigns local addresses like Lance.Boyle, LanceBoyle, lance.boyle and lanceboyle and treats them as different might be the source of other kinds of trouble.


答:
In his book Clean Code Robert C. Martin argues that methods in a class should be order by  the order of use in the class. That is start with a public method, then the private methods that public method uses in the order it uses them. The private methods used in the those private methods follow right after the method that uses them. Then the next public methods, followed by its associated private methods. That way, when reading a method, the other methods is uses are right below.

For this approach to be effective, though, classes really need to be small, and have a single responsibility.


问:
Stuff every programmer needs while working
I've been tasked with creating a fun and relaxing environment, one thing I know that I want is ergonomic mice and keyboards, others have suggested exercise balls and bands.

What is it that every programmer needs while working? What might not be necessary but would be nice to have anyway?

Note: this question was asked previously, but has been recommended to be posted here. See this link for the previous responses: https://stackoverflow.com/questions/3911911/stuff-every-programmer-needs-while-working-closed

答:
Coke.

BTW, dual monitors are overrated.

Body:
Coke.

BTW, dual monitors are overrated.


问:
How Much Logic in Getters
My coworkers tell me there should be as little logic as possible in getters and setters.

Yet, I am convinced that a lot of stuff can be hidden in getters and setters to shield users/programmers from implementation details.

An example of what I do:

```<code>public List<Stuff> getStuff()
{
   if (stuff == null || cacheInvalid())
   {
       stuff = getStuffFromDatabase();
   }
   return stuff;
}
</code>```

An example of how work tells me to do things (they quote 'Clean Code' from Uncle Bob):

```<code>public List<Stuff> getStuff()
{
    return stuff;
}

public void loadStuff()
{
    stuff = getStuffFromDatabase();
}
</code>```

How much logic is appropriate in a setter/getter? What's the use of empty getters and setters except a violation of data hiding?

答: IMHO it is very simple if you use a design by contract. Decide what should your getter provide and just code accordingly (simple code or some complex logic that may be involved or delegated somewhere).</p>

Title: How Much Logic in Getters


问:
What is the difference between a pointer pointing to 0x0 location and a pointer set to NULL?
Is a pointer pointing to 0x0000 the same as a pointer set to NULL? If NULL value is defined in the C language, then what location does it physically translate to? Is it the same as 0x0000. Where can I find more details about these concepts?</p>

答:
Every platform out there is free to define NULL as it pleases.

According to the C Standard, if you assign zero to a pointer it will be converted to a NULL value (for that platform.) However, if you take a NULL pointer and cast it to int, there are no guarantees that you will get zero on every platform out there. The fact however is that on most platforms it will be zero.

Information about that stuff you can find in The C Language Specification. You can find them here.


答: It is defined in the C language because there is no one unvarying machine address that it equates to. If it did, we wouldn't need an abstraction from it! Even though on most platforms, NULL might eventually be implemented as 0 of some type or other, it's simply wrong to assume that this is universally so, if you care about portability at all.

Title: What is the difference between a pointer pointing to 0x0 location and a pointer set to NULL?

Body: Is a pointer pointing to 0x0000 the same as a pointer set to NULL? If NULL value is defined in the C language, then what location does it physically translate to? Is it the same as 0x0000. Where can I find more details about these concepts?</p>


答:
According to C Standard Document section 6.3.2.3:

An integer constant expression with the value 0, or such an expression cast to type void *, is called a null pointer constant.55) If a null pointer constant is converted to a pointer type, the resulting pointer, called a null pointer, is guaranteed to compare unequal to a pointer to any object or function.

So far I have not seen a compiler that has broken away from this.


问:
several similar tables vs several one-to-one relationships?
I have a sort of blog application that I'm working on for constrained writing. The posts have several types, and share some columns in common (title, body for instance), but they also have columns that they don't share in common. Please correct me if I'm wrong, but I feel like my two database design options are:

Create a separate table for each type of post (and then use UNION if I ever need to select all of the various types).

Create one table to store all of the similar columns (and then have several one-to-one relationships to define what's different about them--like an inheritance-type situation).

Which is better? Why? Are there other designs that would be better?

UPDATE:  these posts will be different types of constrained writing (I.e., poems), that are validated in specific ways based on the particular constraint technique, and may have a variety of other tables associated with them, so extensibility will be really important. That said it sounds like either the nosql or inheritance options would be best. I would just be worried about doing analytical stuff with nosql (never used it, so I just don't know anything about how to aggregate, etc, with it).

答:
Third option:

Create one table containing all columns and allow nulls for the non-common fields.

This will make for fast reads and remove the need for joins.

Whether it is better than your other options depends on your requirements.


答:
I prefer the second option, the hierarchy. But it gets complicated very soon, and I don't really think you want that for a blog. You could of course go with a god table that fits all posts, and has a lot of null values for optional fields, but that won't really scale well.

I think the scenario, as you describe it, is perfect for a schema-less document-oriented storage, a NoSQL solution like MongoDB or Apache CrouchDB. There are others, of course, these are the two I'm more familiar with. You are looking for a flexible schema, what better solution from a schema-less one?

If a NoSQL solution is not an option, you should balance the relational options on potential complexity, maintainability, and scalability. If you don't have a pretty good idea of how your database will grow, it's going to be a very tough decision, but still one you'll have to make for yourself.

Title: several similar tables vs several one-to-one relationships?

Body:
I have a sort of blog application that I'm working on for constrained writing. The posts have several types, and share some columns in common (title, body for instance), but they also have columns that they don't share in common. Please correct me if I'm wrong, but I feel like my two database design options are:

Create a separate table for each type of post (and then use UNION if I ever need to select all of the various types).

Create one table to store all of the similar columns (and then have several one-to-one relationships to define what's different about them--like an inheritance-type situation).

Which is better? Why? Are there other designs that would be better?

UPDATE:  these posts will be different types of constrained writing (I.e., poems), that are validated in specific ways based on the particular constraint technique, and may have a variety of other tables associated with them, so extensibility will be really important. That said it sounds like either the nosql or inheritance options would be best. I would just be worried about doing analytical stuff with nosql (never used it, so I just don't know anything about how to aggregate, etc, with it).


答:
Sounds like this might be a bit of a purist versus application debate that might be affected by how you prefer to control function names. From the applied standpoint, I would much rather see:

```<code>List<String> names = clientRoster.getNames();
List<String> emails = clientRoster.getEmails();
</code>```

As opposed to:

```<code>myObject.load();
List<String> names = clientRoster.getNames();
List<String> emails = clientRoster.getEmails();
</code>```

Or even worse:

```<code>myObject.loadNames();
List<String> names = clientRoster.getNames();
myOjbect.loadEmails();
List<String> emails = clientRoster.getEmails();
</code>```

Which just tends to make other code much more redundant and harder to read because you have to start wading through all of the similar calls. Additionally, calling loader functions or similar breaks the whole purpose of even using OOP in that you are no longer being abstracted away from the implementation details of the object you are working with. If you have a clientRoster object, you shouldn't have to care about how getNames works, as you would if you have to call a loadNames, you should just know that getNames gives you a List<String> with the names of the clients.

Thus, is sounds like the issue is more about semantics and the best name for the function to get the data. If the company (and others) has an issue with the get and set prefix, then how about calling the function something like retrieveNames instead? It says what is going on but doesn't imply that the operation would be instantaneous as might be expected of a get method.

In terms of logic in an accessor method, keep it to a minimum as they are generally implied to be instantaneous with only nominal interaction occurring with the variable. However, that also generally only applies to simple types, complex data types (i.e. List) I find harder to properly encapsulate in a property and generally use other methods for interacting with them as opposed to a strict mutator and accessor.

Title: How Much Logic in Getters

Body:
My coworkers tell me there should be as little logic as possible in getters and setters.

Yet, I am convinced that a lot of stuff can be hidden in getters and setters to shield users/programmers from implementation details.

An example of what I do:

```<code>public List<Stuff> getStuff()
{
   if (stuff == null || cacheInvalid())
   {
       stuff = getStuffFromDatabase();
   }
   return stuff;
}
</code>```

An example of how work tells me to do things (they quote 'Clean Code' from Uncle Bob):

```<code>public List<Stuff> getStuff()
{
    return stuff;
}

public void loadStuff()
{
    stuff = getStuffFromDatabase();
}
</code>```

How much logic is appropriate in a setter/getter? What's the use of empty getters and setters except a violation of data hiding?

Body:
Sounds like this might be a bit of a purist versus application debate that might be affected by how you prefer to control function names. From the applied standpoint, I would much rather see:

List<String> names = clientRoster.getNames();
List<String> emails = clientRoster.getEmails();

As opposed to:

myObject.load();
List<String> names = clientRoster.getNames();
List<String> emails = clientRoster.getEmails();

Or even worse:

myObject.loadNames();
List<String> names = clientRoster.getNames();
myOjbect.loadEmails();
List<String> emails = clientRoster.getEmails();

Which just tends to make other code much more redundant and harder to read because you have to start wading through all of the similar calls. Additionally, calling loader functions or similar breaks the whole purpose of even using OOP in that you are no longer being abstracted away from the implementation details of the object you are working with. If you have a clientRoster object, you shouldn't have to care about how getNames works, as you would if you have to call a loadNames, you should just know that getNames gives you a List<String> with the names of the clients.

Thus, is sounds like the issue is more about semantics and the best name for the function to get the data. If the company (and others) has an issue with the get and set prefix, then how about calling the function something like retrieveNames instead? It says what is going on but doesn't imply that the operation would be instantaneous as might be expected of a get method.

In terms of logic in an accessor method, keep it to a minimum as they are generally implied to be instantaneous with only nominal interaction occurring with the variable. However, that also generally only applies to simple types, complex data types (i.e. List) I find harder to properly encapsulate in a property and generally use other methods for interacting with them as opposed to a strict mutator and accessor.


答:
If it's pride that's preventing you from going back to school, let it go. A degree is a powerful thing, it opens doors. It's a challenge, but you sound intelligent, I recommend you figure out how to balance your personal and work life and go back to school, even for an associates degree.

To answer your question, number of years equivalent? 7-10 years at the same job. Toss on a certification exam and I think you'd have a level playing field.

Body:
I'm currently in my placement year and working for a great software development company. It was always my intention of getting to this stage through university, getting enough academic experience as well as the year’s placement and then try to get a full time programming job without the need to finish my degree. I decided this from an early stage as I have never really liked the whole university environment. I was so unhappy at university and I’m so happy now I’m on my placement year, I really don’t know if I can go back.

My question is, do you think companies will take me on if I apply for other jobs after my placement year and not penalize me for not finishing my degree?

I guess at the end of the day I don't want to look back on my life and think "god, why didn't I just spend one more year being unhappy to have a job I love" but I know that even if I get a degree I could still end up without a programming job and this worries me more than anything.


问:
Are null references really a bad thing?
I've heard it said that the inclusion of null references in programming languages is the "billion dollar mistake".  But why?  Sure, they can cause NullReferenceExceptions, but so what?  Any element of the language can be a source of errors if used improperly.

And what's the alternative?  I suppose instead of saying this:

Customer c = Customer.GetByLastName("Goodman"); // returns null if not found
if (c != null)
{
    Console.WriteLine(c.FirstName + " " + c.LastName + " is awesome!");
}
else { Console.WriteLine("There was no customer named Goodman.  How lame!"); }
```

<p>You could say this:</p>

<pre class="lang-cs prettyprint-override"><code>if (Customer.ExistsWithLastName("Goodman"))
{
    Customer c = Customer.GetByLastName("Goodman") // throws error if not found
    Console.WriteLine(c.FirstName + " " + c.LastName + " is awesome!");
}
else { Console.WriteLine("There was no customer named Goodman.  How lame!"); }
</code>```

But how is that better?  Either way, if you forget to check that the customer exists, you get an exception.

I suppose that a CustomerNotFoundException is a bit easier to debug than a NullReferenceException by virtue of being more descriptive.  Is that all there is to it?

答:
There are several problems with using null references in code.

First, it's generally used to indicate a special state. Rather than defining a new class or constant for each state as specializations are normally done, using a null reference is using a lossy, massively generalized type/value.

Second, debugging code becomes more difficult when a null reference appears and you attempt to determine what generated it, which state is in effect and its cause even if you can trace its upstream execution path.

Third, null references introduces additional code paths to test.

Fourth, once null references are used as valid states for parameters as well as return values, defensive programming (for states caused by design) requires more null reference checking to be done in various places…just in case.

Fifth, the language's runtime is already performing type checks when it performs selector lookup on an object's method table. So you're duplicating effort by checking if the object's type is valid/invalid and then having the runtime check the valid object's type to invoke its method.

Why not use the NullObject pattern to take advantage of the runtime's check to have it invoke NOP methods specific to that state (conforming to the regular state's interface) while also eliminating all the extra checking for null references throughout your codebase?

It involves more work by creating a NullObject class for each interface with which you want to represent a special state. But at least the specialization is isolated to each special state, rather than the code in which the state might be present. IOW, the number of tests are reduced because you have fewer alternate execution paths in your methods.

Title: Are null references really a bad thing?


问:
How do you keep track of large projects?
When dealing with a project that has many different files, I always seem to loose track of how the parts interact with one another. I've never really had much of a problem understanding smaller components in isolation, but as the complexity of the project increases, I find myself unable to mentally construct an understanding of what is going on. I notice this especially with OOP projects, as the number of methods and source files increase.

My background:
I'm a self-taught web programmer. I've dealt mostly with python for quick and dirty scripts, but I've also done a few basic django projects. I like web frameworks such as flask, because in the simplicity of a single-file layout, I can easily keep track (mostly) of what is going on.

I now find myself in a situation where I need to interact with a large Zend Framework PHP project that someone else developed, and I'm overwhelmed with trying to understand the code spread out to numerous files.

What techniques and processes have you found useful to understand a large code base that someone else has developed? Is there any particular diagram that you find helps you grasp the larger picture?

答:
The trick to understanding a large code base is to not try to understand all of it.  After a certain size, you can't hold a mental model in your head of the entire thing.  You start with an anchor point that makes sense for whatever task you need to work on first, then branch from there, learning only the parts you need and trusting that the rest of it works as advertised.  It's just like understanding recursion.  If you try to hold the entire stack in your head your brain explodes.

Grep, debuggers, and intellisense are your friends here.  If you don't know how a function ends up getting called, set a breakpoint on it and work your way down the stack trace.

The other thing to note is that large code bases don't spring up out of nowhere.  The larger it is, the more programmers there are with experience on it, so ask them where to start, but be specific.  Ask questions like, "I need to add a new payment provider.  Where in the code should I be looking?"  Focus on just that task instead of trying to understand the entire code base, and piece by piece your familiarity will grow.