问:
mind map for programmers
How are mind maps useful for programmers in organizing the way they work?</p>

答:
As with every other tool this one can be misused badly.  I find any tool that facilitate me to write better software is a tool worth using.  Mind maps, especially in early phases can give you an edge so that you (and your users) can get a clear idea of what is being done.  However, it is easy to get carried away:

Source is unknown -- I do not remember where I got it from and there is no information within the images to offer suggestions.

Title: mind map for programmers


问:
Simple explanation of the Unix sockets
I can search and I've already looked at the wikipedia entry and in some other places, but even though I have some programming experience, I don't really grasp the concept. Can you treat me like a 10 year old and give me a clear explanation on socket communication?</p>

答: Programming Linux sockets, Part 1: Using TCP/IP worked quite well for me. It starts with an introduction to IP networks and network layers, then goes on by showing how to implement a simple echo server and client in both C and Python.</p>

ContentLicense: CC BY-SA 3.0

Title: Simple explanation of the Unix sockets


问:
Does commentary style affect how readers understand code?
This question has been obsessing me for the past 2 months.

A while ago a friend who is a great programmer gave me some example codes, and for the first time I've noticed a unique style of organizing comments. He took some effort to design comments in a way that would make me more comfortable with the code itself. For example:

```<code>/////////////////////////////////////////////                                                   //                                             //
//  This code prints a basic "Hello world" //
// message to the console screen. You can  //
// change the text in the brackets.        //
//                                         //
/////////////////////////////////////////////

#include <iostream>

int main() {
  cout << "Hello world";

}
</code>```

when he could have simply written

```<code>/* This code prints a basic "Hello world" message to the console, change text in brackets */

 #include <iostream>

int main() {
  cout << "Hello world";

}
</code>```

This kind of example only on a bigger scale. I find this a little unproductive in professional situations but in a learning situation, it seems ideal.

The question here is, if comment style affects how the reader understands code. In my personal opinion option #1 is prettier to the eye and easier to follow than #2. Does the way you comment on code affect ones ability to comprehend your code, or is it just wasted time and space?

答:
A quick answer to the question is “Yes”. Comments and commentary style clearly affect the readability and understandability of the code. That's the general idea, but the quality of comment descriptions and their design is purely subjective.

Have you ever tried reading someone else’s code and comments? Most programmers write code and comments based on their own style and level of knowledge. Reading their comments and code is like trying to get into their mind and follow their practices.

One way to avoid this issue is to use a basic “principle/style guide” that briefly describe the basic guidelines for code structure, purpose, and comments. This guide must be consistently followed by the people who write the code and all the rest who might read the code and possibly extend it.


问:
What are the advantages of separating 'result' from 'status'
Let's say you have some automated processes that generally go through the following states;
scheduled - initiated - validating - executing - completed

On top of that these processes can prematurely end because of an error or explicit user cancellation.

My first impulse is to simply add error and cancelled to the list of possible status values, but I was wondering about the (conceptual) advantages of separating result from status (even though it seems to me that one might argue that error and cancelled are also simply different states than the completed state).

答:
but I was wondering about the (conceptual) advantages of separating result from status (even though it seems to me that one might argue that error and cancelled are also simply different states than the completed state).

There is a great advantage in detailing progress and identifying failiure points (within reasonable limits) as in your case.
I think the confusion stems from the terms 'status' and 'state' - We must qualify those terms. So for example, "Task Status", even that is not very precise, so we may want to use "Task Execution Status", however this is wrong because you already have an execute step. We may use the name "Task Processing Status" and the values of: "initiated - validating - executing - completed" make perfect sense. Indeed we could add 'Cancelled' to the list. However, 'Error' does not answer a question like: What is the Task Processing Status very well. It looks like 'Error' is a sub-status of Completed. So what do we do? We could rename Completed to be Completed OK and then we could add Completed With Error to the list. So the final list of the Task Processing Status values are:

Initiated,

Validated,

Executing,

Cancelled,

Completed OK,

Completed With Error

Edit: now the above list still requires some work. The first 4 items don't have the word 'OK' in them. So if it better be there to match the "Completed OK" state. The other thing is that the first 4 items don't have a "with error" - What doe that mean? What happens when "Executing" abnormally ends - Does that call for a new state of "Executed with Error"? At this point, more input and analysis may be required.


问:
Can a CS degree benefit an older programmer?
Is there any benefit in getting a CS degree in ones mid 40's career wise?   Would the increased likelihood of getting past the HR filter be worth it?

It's something I might actually enjoy doing, and I wouldn't mind solidifying my fundamentals, but I would be reducing my earning capacity during the years it would take to complete the degree, and by the time I'm done, I'll have maybe 15 years left in my career.

(I currently have no college degree)

答: A college degree from an accredited college always proves beneficial when looking for jobs. The truth is employers give preference to people with college degrees and more so if the job you're applying for requires specialized technical skills. While I understand the thought of going back to college when you're in your forties might be a little unnerving, but it doesn't have to be. Luckily, colleges today offer varied online degree programs which provide the with flexibility and the added advantage of being able to study while working. So I'd suggest you look into a program best suited for you and make a well informed decision which is likely to help further your career in the long run.</p>


问:
How much experience on average should a Sr. developer have to be competent with a framework or library?
If you are a Senior developer with say 8+ years experience, how much time spent doing programming is reasonable for competency on average?  Specifically working with some library or framework associated with the core language they have worked with.  For example, 2 years of Spring or Hibernate for a java developer.

I understand that this is based on the complexity of the toolkit, framework or library, plus the competence of the individual developer, however, I'm sure there are reasonable ranges based on time with a language (hence the reference to Senior) that a Senior developer should be able to get competency and be productive.

The reason I ask the question is IT Managers should know this when writing requirements for a position and as a developer, I would like to have a better idea as to what criteria is involved for this type of experience = competency formula that has to exist.  Even if it's a rule of thumb only.

What prompted this question is that I've found recruiters, who generally don't have a technical background, are trying to place technical people and they just look at technology buzzwords on a resume and how much experience for each the dev has.  The hiring manager oftentimes doesn't have a technical background and does the same thing with the resume and uses his architect or other technical expert to screen the candidate to make sure the resume matches the person in the interview.

The problem here is the perception of "competency" in the mind of the hiring IT manager, whether or not the dev can really pick things up and run with it.  They rely on some formula in their mind as to how much experience the dev has with a technology will work for what they want.

答:
If you're asking about competency then I would say just a couple of months of dedicated effort. mastery, as many point out, is generally accepted to take 10,000 hours to achieve.

The times I've had to learn new technologies -- from complete languages like groovy or python, or frameworks like rails, or GUI toolkits like tk and wxPython -- usually take me just a few weeks to become competent. That means I am able to do my job, but that I still have to look things up. It means if my boss says "can you make product x using framework y in language z" I can confidently say "yes".

To me, that's the difference between senior and junior: senior developers can pick up new toolkits, frameworks and complete languages pretty quickly.


答:
It depends, on too many factors for the question to even be relevant as some fresh college graduates could feasibly be competent with a given framework or library just on the basis of where they went to school and how the program was structured. Likewise, once you start working in industry you tend to find that there is a degree of specialization and companies are a various stages with regards to the current cutting edge (i.e. they are still working with Visual Basic 6).

If you are looking for someone to get something done in the short term where the knowledge is a mandatory item then you are better off hiring a contractor to get the work done. If you are looking for someone for the longer term you are better off looking for someone on the basis of what makes for a good developer and with enough industry experience and competency to justify paying them as a senior developer.

Title: How much experience on average should a Sr. developer have to be competent with a framework or library?

Body:
If you are a Senior developer with say 8+ years experience, how much time spent doing programming is reasonable for competency on average?  Specifically working with some library or framework associated with the core language they have worked with.  For example, 2 years of Spring or Hibernate for a java developer.

I understand that this is based on the complexity of the toolkit, framework or library, plus the competence of the individual developer, however, I'm sure there are reasonable ranges based on time with a language (hence the reference to Senior) that a Senior developer should be able to get competency and be productive.

The reason I ask the question is IT Managers should know this when writing requirements for a position and as a developer, I would like to have a better idea as to what criteria is involved for this type of experience = competency formula that has to exist.  Even if it's a rule of thumb only.

What prompted this question is that I've found recruiters, who generally don't have a technical background, are trying to place technical people and they just look at technology buzzwords on a resume and how much experience for each the dev has.  The hiring manager oftentimes doesn't have a technical background and does the same thing with the resume and uses his architect or other technical expert to screen the candidate to make sure the resume matches the person in the interview.

The problem here is the perception of "competency" in the mind of the hiring IT manager, whether or not the dev can really pick things up and run with it.  They rely on some formula in their mind as to how much experience the dev has with a technology will work for what they want.


答:
There are a lot of variables at play as you need to take the following into account:

Are you going to go back to school full-time?

Odds are that going back to school full time is not going to be to your advantage both due to the financial loss as well as the fact that college culture is no necessarily something that is best enjoyed once you are older.

Do you have the time to invest in night school programs?

If you don't go back to school full time then the next best thing is night school, or an online degree from a reputable school. The catch is that it generally does take you longer to finish a night school program (figure six years unless you are taking classes during the summer) which means that you are going to be giving up the time in the evenings and on the weekends. This can be tough for a number of reasons and might actually prove to be a greater investment than just monetary concerns.

Who is going to pay for the program?

This needs to be mentioned for obvious reasons because the chances are pretty good that while you might make back money you invest in the degree over the remainder of your career, it is questionable if you will come out significantly ahead by by the time you retire. That said though, if you work for a larger company with education benefits then they might pay for the degree in which case your only investment is the time as opposed the money.

Do you really need a Bachelors degree?

If you are just looking to get past the HR filters, then an Associates degree might be enough in and of itself. No guarantees here though and most Associates degree programs tend to focus more on the applied programming skills as opposed to theory which is what you might be a bit lacking unless you studied on your own.

Do you really want to get a degree in general?

If you don't want to get a degree, then don't get one. Odds are that you have enough experience at this point that not having a degree isn't as big of a hindrance as you might think and while some some large companies might not be interested in you, at this point getting the degree might not even help. There is something to think about though, most companies don't really care as much as they let on in regards to what you have the degree in and if you are thinking about taking courses for personal development then you might want to just think about doing that instead.

Title: Can a CS degree benefit an older programmer?

Body:
Is there any benefit in getting a CS degree in ones mid 40's career wise?   Would the increased likelihood of getting past the HR filter be worth it?

It's something I might actually enjoy doing, and I wouldn't mind solidifying my fundamentals, but I would be reducing my earning capacity during the years it would take to complete the degree, and by the time I'm done, I'll have maybe 15 years left in my career.

(I currently have no college degree)


问:
Is musical notation Turing-Complete?
I'm wondering, is music notation language Turing-Complete?

My first thought is that there are loops in musical notation, but there is no way to write conditional branches, right?

I'm not a musician, so perhaps someone can help fill in the gaps?

答: Turing completeness requires, at a minimum, three things: an infinite loop, a conditional jump (if-then), and a way to store the results of calculations to somewhere in memory.  Even if musical notation had conditional jumps, it doesn't have state, so no, it's not Turing-complete.

Title: Is musical notation Turing-Complete?


答:
It is hard to answer whether or not there would be value to each and every person to get their degree.  I spent the first major part of my career thinking I did not need to go to school.  But now I have started back a year and a half ago. I am a huge advocate in getting the degree. I have been doing hardware/infrastructure support for nearly 13 years, and chose to get my Bachelor's in CS.

There are two points that I wanted to touch upon about value behind a degree (outside the angle of HR interviews)

Intangible Skills: These are the skills that make you a valuable asset to an employer, that are impossible to measure or document.  Skills learned through working through problems and projects, and meeting deadlines (whether in class or in the real world).  Learning from your own experiences in school can translate to be invaluable when resolving major technological issues in a professional environment. I have found a lot of my perspective on problem solving has been learned 'accidentally' in my Gen Ed classes. I personally find that all of my classes have added value, assisting me in looking at issues and problems from different perspectives.  If anything, working with non-IT people in my Gen Ed classes, have helped me gain a different perspective on clients.

Base Technical Skills As stated, technology changes rapidly, so it is very hard to gain a degree with the most recent technologies is impossible.  But, the truth is, there is hardly any technology being created that is not an offshoot or spin off of another.  If a degree program offers a good base of technological concepts, you may find yourself learning not just how to make stuff work, but how and why it works.  I have encountered far too many professionals in my career that just focus on learning to make things work, without understanding why. I have found in my studies (tech school over 8 years ago and current University) that the most important technology I have learned is the base highly technical topics, that have assisted in transitions to new technologies.  As an example, a OS class where you tear apart the structure of the software, and understand topics such as how the OS interacts with hardware and 3rd party software would be helpful dealing with work in nearly any OS.  Yes, on the surface and the APIs of the OSs are very different, the basics of how they interact with the machine are the same.

Maybe I am less bitter about Education, because I spent 9 years spinning my wheels in what was a dead end job, thinking that that was where I was going to spend the rest of my life.  I decided to take a chance on a fairly large corporation, and was instructed during my interview that my skill set was perfect, and that they wanted to hire me.  Through positive reinforcement, they kicked me in the butt to get back into school, and are now paying 75% of tuition. As I said, it is hard to put a worth on it, and say if its worth it for you or not.  It all depends on what you are looking to gain from it.


问:
If Instance is for Class, what's for Template?
I am not able to find the right technical term to mention child or instance of a template.

What's the right one, child or instance or something else I am not aware of?
Sorry for my unclear original question.

Its not related to any language. The Template I am talking about is a business concept in my application.
Say for example, I have a "chair" template. I would set a few property values to it to create it's usable instances.
I need this for naming and documentation stuff.

Shortlisted 3 terms: Instance, Definition, Child. Whats suits better?

答: According to the book C++ Templates - The Complete Guide (chapter "Termonology"), it is called "specialization". The process of creating a specialization is called instantiation. </p>


问:
Can someone who studied web easily switch to software
I'm applying to university very soon, and I have my mind set on programming. I narrowed down my program options to Web Services and Applications, Computer Applications, and Computer Games.

I'm leaning towards Web, since I've been developing for Web since college.

Question

So, my question is, would it be very difficult to switch career path from Web to Software for example should I find years from now that I would have preferred a different career path?

Note

The three programs are all part of a Bachelor of Computer Science and seem to share the same basic courses.

答:
My experience is that university will give you a better, deeper understanding of the concepts and theory involved in computer science and software design in general.

How you choose to apply that understanding is entirely up to you.

If your university offers you a web paradigm course, it will likely delve into issues and considerations specific to development in that environment.  This won't be exclusive, they're still going to give you a broad set of tools.

I surmise that most of what you will learn will be transferable, though you would need to brush up on topics relevant to the new domain ... possibly through courses or participation in open source software, etc.


答: Do you have to choose right away? I'd think that the first year or two of all those programs would have a lot in common. It's very common for students to switch majors entirely, from maybe English to Biology or whatever. So even if you pick something now, you should be able to change your mind for quite some time to come.</p>

Title: Can someone who studied web easily switch to software

Body:
I'm applying to university very soon, and I have my mind set on programming. I narrowed down my program options to Web Services and Applications, Computer Applications, and Computer Games.

I'm leaning towards Web, since I've been developing for Web since college.

Question

So, my question is, would it be very difficult to switch career path from Web to Software for example should I find years from now that I would have preferred a different career path?

Note

The three programs are all part of a Bachelor of Computer Science and seem to share the same basic courses.


答:
Stylistically, I would go with two forms of comment (for C++/Java)

```<code>/**
 * Multi-line comment
 */
</code>```

or

```<code>// Single-line comment
</code>```

an IDE with syntax highlighting is enough to draw your attention to the comment, you do not need to get fancy with the formatting.

Title: Does commentary style affect how readers understand code?

Body:
This question has been obsessing me for the past 2 months.

A while ago a friend who is a great programmer gave me some example codes, and for the first time I've noticed a unique style of organizing comments. He took some effort to design comments in a way that would make me more comfortable with the code itself. For example:

```<code>/////////////////////////////////////////////                                                   //                                             //
//  This code prints a basic "Hello world" //
// message to the console screen. You can  //
// change the text in the brackets.        //
//                                         //
/////////////////////////////////////////////

#include <iostream>

int main() {
  cout << "Hello world";

}
</code>```

when he could have simply written

```<code>/* This code prints a basic "Hello world" message to the console, change text in brackets */

 #include <iostream>

int main() {
  cout << "Hello world";

}
</code>```

This kind of example only on a bigger scale. I find this a little unproductive in professional situations but in a learning situation, it seems ideal.

The question here is, if comment style affects how the reader understands code. In my personal opinion option #1 is prettier to the eye and easier to follow than #2. Does the way you comment on code affect ones ability to comprehend your code, or is it just wasted time and space?

Body:
Stylistically, I would go with two forms of comment (for C++/Java)

/**
 * Multi-line comment
 */

or

// Single-line comment

an IDE with syntax highlighting is enough to draw your attention to the comment, you do not need to get fancy with the formatting.


答:
In your first few years of college, your core classes should be the same with whichever degree you pick of those.  The point of the degree isn't to force you into one specific area, but prepare you for a wide variety of fields within the CompSci realm.  The Web Services and Computer Applications degrees sound very similar, the Game one may have more classes that deal with 3D graphics and such. At my university, all of these would be under the degree of Computer Science with a focus on whichever field.  </p>

<p>What I would say to you is, do whichever you're going to enjoy more, because all of these degrees will open the door for you to go into almost any field within Computer Science (as long as it isn't super specialized ie. Bioinformatics) so it's really up to you.  It's so important for you to enjoy your education rather that just seeing it as something you need to get through.  </p>

Body:
In your first few years of college, your core classes should be the same with whichever degree you pick of those.  The point of the degree isn't to force you into one specific area, but prepare you for a wide variety of fields within the CompSci realm.  The Web Services and Computer Applications degrees sound very similar, the Game one may have more classes that deal with 3D graphics and such. At my university, all of these would be under the degree of Computer Science with a focus on whichever field.

What I would say to you is, do whichever you're going to enjoy more, because all of these degrees will open the door for you to go into almost any field within Computer Science (as long as it isn't super specialized ie. Bioinformatics) so it's really up to you.  It's so important for you to enjoy your education rather that just seeing it as something you need to get through.


答: It's hard to understand what template means in this context but in one conceptual interpretation of the word an instance of a template could be considered a prototype, or perhaps archetype, blueprint, definition

Title: If Instance is for Class, what's for Template?

Body:
I am not able to find the right technical term to mention child or instance of a template.

What's the right one, child or instance or something else I am not aware of?
Sorry for my unclear original question.

Its not related to any language. The Template I am talking about is a business concept in my application.
Say for example, I have a "chair" template. I would set a few property values to it to create it's usable instances.
I need this for naming and documentation stuff.

Shortlisted 3 terms: Instance, Definition, Child. Whats suits better?


问:
How can I debug a memory leak in a service
I have a windows service program that is running on one of our servers.  It has a memory leak of some kind within the program.  When it first starts running it is using 20,000k memory.  Within a few days it is up to 400,000k of memory.  It is a fairly simple program that tracks running processes and writes the information to a database.

I am unsure on how I can debug a program running on a remote machine to find out where the memory leak is coming from.  What methods would you suggest I use in order to try and track this down?

Update

The program has a lot of exception handling in place already.  However, it has no logging whatsoever.  What information should I be logging in order to track down the memory leak?

答:
There are a number of ways that come to mind:

Run the service locally, but not as a service.  Create your own lightweight host environment such as a simple console app.  You can now attach memory profiling tools (the one built into certain versions of Visual Studio, etc).

You can do Core Dumps when the memory is large.  This is non-trivial and you'll need some tools from the Windows SDK.

Do you have any logging in place?  If so, you could compare what's happening in your logs against some PerfMon data.


答:
So, my question is, would it be very difficult to switch career path from Web to Software
  for example should I find years from now that I would have preferred a different career path?

If you're smart, then no, it's not difficult at all. I didn't do any web programming in university, but for the first few years out of school that's what I did because that's where I found work.


答:
Yes, commenting style certainly affects readability. Any comment style that lets me identify comments quickly so I can avoid reading them helps tremendously when what I'm really trying to do is read the code.

Even better is a code commenting style that lets me use the IDE minimize the comments right out of view altogether, so I don't have to expend the energy to read around them.


答:
The standard proof for a language to be Turing complete is to write a Turing machine in that language.  This proves that there's an equivalence between the language (usually a subset of the language) and the Turing machine.

The notion of "Musical Notation" is a bit slippery.  There is a lot of standardized engraving that is used.  However.  There are envelope-pushing composers who write all kinds of crazy stuff down on paper.

Let's pretend you want to focus on the subset of musical notation that is considered standard enough to be part of Finale or Sibelius or some  main-stream engraving toolset.

So.

For Python (or C or whatever) you define the symbols, the tape, the transition rules, and the various actions which update the tape to reflect state change and tape motion, reading and writing symbols on the tape.

Using "Musical Notation", we have to define symbols and the stateful tape, the transition rules and the various actions which update the tape.

What we lack is a stateful tape and rules that tell the musicians how how to responds to symbols on the tape and how to update that tape.

In a sense, the noises flowing around in the air might be the stateful tape.  But.  There's no easy way to rewind the tape.  This lack of rewind means that the performer would have to keep a private "tape" of some kind.

This gets outside musical notation and into some other extra-musical instructions to the performer.

Title: Is musical notation Turing-Complete?

Body:
I'm wondering, is music notation language Turing-Complete?

My first thought is that there are loops in musical notation, but there is no way to write conditional branches, right?

I'm not a musician, so perhaps someone can help fill in the gaps?


问:
How do programmers quit a job?
I'm thinking about leaving my current employer and wondering how one goes about that process in the programming world. We have a lot of projects on the go at the moment and I'm the only developer. We have 4-5 projects that are fairly big and need to be done in the next few months and even a few longer than that.

I'm leaving because I'm the only employee and that's doing me no good. I'm young and want to learn, so a team would be nice. It's also too much work and the company is managed horribly.

I have no contract to worry about so I could theoretically quit and just not come back without notice. Just wondering how this is normally handled.

Should I write a resignation letter

How much notice should I give

Should I give a reason for leaving

Should I go to my boss who is the main reason I'm leaving or go to his boss?

Overview of replies

From the feedback here, it looks as though it's best to give 2-4 weeks of notice, and present a written resignation. Don't go into detail explaining why you're leaving in most cases. Don't burn bridges. Be professional.

答:
Is there any chance of salvaging the situation?  Of them hiring additional people, for example?

Unless programming jobs are plentiful and easy to get where you are, or your plan is to take 6 months off and backpack in the Andes or something, I'd start the job hunt process first, before you leave.  Get your resume together and start searching job boards, ideally lining up interviews and having an offer waiting.  You dont want to run off to greener pastures unless you know they actually exist.  If this was 1999, the height of the dot-com boom when you couldnt stumble six feet without being offered a high paying programming job, I'd tell you to jump ship without looking.  But, alas, its not.

If you do leave, follow the advice others have listed - ample notice, dont delete anything, etc.

ContentLicense: CC BY-SA 2.5

Title: How do programmers quit a job?


答:
Much of the notation is open to interpretation, and natural language instructions are an accepted aspect of musical notation -- and have been throughout most if not all of the history of Western notated music.

Fermatas by definition depend on the performer's discretion, which means that it would depend on their own state, which is almost always altered by the music in conjunction to external factors -- so this raises some questions on the stateless nature of musical notation.

Canon a 2 per Tonus from Bach's Musical Offering is an infinitely looped piece whose tonality rises by a whole step each time through for as long as the piece is performed.

More recently, it's common to see instructions such as "repeat for each soloist" in, for instance, notated versions of Jazz pieces such as Dave Brubeck's Take Five.

That said, aside from inherently arbitrary aspects like the fermata, as the other answers state, musical notation with nothing but the general symbols is probably not Turing complete.

Title: Is musical notation Turing-Complete?


答:
It is not related to Turing complete languages as it is a descriptive language. There are no commands in terms of calculation or modifying data, no states, no input, no output except for the result of the description itself.

Also there are no conditional jumps depending on the input. When you resolve all the jumps you get a linear structure, not a tree. So all "programs" which can be modelled by this language are linear without any loops or jumps at all.

Title: Is musical notation Turing-Complete?


答:
I think there are a still (quite a few) people who see web development as the "ugly stepsister" of what they think of as "real" development. As such, it's probably somewhat easier to get a job doing web development if the degree says your emphasis was in application development than vice versa.

I wouldn't worry a lot about making a hard and fast decision immediately though. Yes, when you start college, they (generally) require you to declare a major, but don't view it as being carved in stone -- especially during the first year or two, it's usually quite easy to change with little or no loss. Of course, the bigger a change you make and/or the longer you wait to make it, the more likely it is that you'll end up having taken some courses that don't apply, but you're not talking about a huge change here -- spending some time exploring won't hurt a thing.


答:
If you are anything like the norm, you will most likely discover 5-10 years from now that what you studied had pretty little impact on what your career ended up being. I studied physics, now I run software teams. Guy next to me has a masters in chemistry and he's a project manager now.

Pick a program that interests you (that you will work hard on) and that you think will develop your academical and analytical skills. University is for learning how to learn and how to apply analytical thinking and reasoning on solving problems.


答:
The way I've approached this problem was to look for threads and objects that weren't being properly disposed/released. This may be due to odd programming errors or unexpected data causing processes to lock up, network device problems and so forth. The problem is that these can sometimes be hard to detect or duplicate when you're running outside of the production environment.

To help track down these problems, provided test cases and/or memory profiling on your development systems don't reveal them right off, you'll need to have good logging and exception handling in place. Watch especially for situations where a thread/object sticks around longer than it should.

Title: How can I debug a memory leak in a service

Body:
I have a windows service program that is running on one of our servers.  It has a memory leak of some kind within the program.  When it first starts running it is using 20,000k memory.  Within a few days it is up to 400,000k of memory.  It is a fairly simple program that tracks running processes and writes the information to a database.

I am unsure on how I can debug a program running on a remote machine to find out where the memory leak is coming from.  What methods would you suggest I use in order to try and track this down?

Update

The program has a lot of exception handling in place already.  However, it has no logging whatsoever.  What information should I be logging in order to track down the memory leak?


答:
Services that run 24x7 are very hard to debug for memory leaks (and also for memory corruption).

There are two lines of attack to achieve memory leak free services:

A. Debug to fight it out

Some tools that can readily provide insight in this are
Valgraind, IBM Rational Purify, memwatch and there are many more so on. Here is a good article that talks about such tools: http://www.linuxjournal.com/article/6556

Run individual modules in a long run; this is kind of unit test but not mock methods. Run a rather meaningful application that uses minimum units first, once you establish that component A is leak free, add in the application B and then C and so on. This will allow isolated

Run different type of loads - first without any meaning full work then other specific type of transaction/work items and so on. Basically try to identify different potential path - basically isolate different code coverage lines that identifies

Log all memory allocations (this is hard to analyse) whether it is due to unnecessary allocations, or forgotten deletions.

Focus on running data - for example packets in network stack or, items generated per transactions, items generated (or forget to delete) per unit of work. What you should do is that identify exact memory usage - and track it per transaction by transaction. And you can again check if certain type of work produces noticeable leaks against otherwise.

Track all small structures, string carefully; mostly such leaks are better caught by code reviews than by tracking memory usage because they are kind of very minor leaks.

B. Design to prevent system

Use local memory as much as possible (basically don't try to keep things heap - but not if there is a perform penalty).

Define clear allocation and deallocation responsibility. As a general rule, the application must allocate and consequently de-allocate and library doesn't have any responsibility in some case.

classify running data structures vs. infra. For example basic objects that are expected to run across the full life cycle vs. objects that gets generated and dies with every transaction/operation etc. The first class (infra) must be all allocated before practical operation starts and during the run time, only work specific data structures allocated; i know that is not always possible or must - but it helps to see that once all infra element are allocated, the memory should be stable

Create system design as modular as possible. Every module should have a very simple abstract of data exchange and/or object creation deletion

Clean up memory on exception. Not removing memory on failed allocations or creators is one of the difficult thing to fight,because everything works for 99% of time, but after 5 days you see some leaks which has no explanation!

Life pools - one of the beauty of Apache web server is that you don't do any free! What it does is that all infra objects (such as core objects, plug-ins etc.) are created a prior. If there is leak in every transaction, over time it will kill memory. What Apache does, is that it creates different life pool - per transaction, medium term and long term pools. Crux is, for the per transaction pool you can just keep alocating. Once transaction is over -the whole bunch is freed at once.
Read this reference that gives you details on how this work.
http://www.fmc-modeling.org/category/projects/apache/amp/4_6Memory_resource.html

Similarly you can also design system (or parts) with static pools. However, this might be difficult for many systems. But such a thing is quite common in embedded systems. see here for details: http://wyw.dcweb.cn/static_mem_pool.htm

Finally, Remember nothing is 100% leak free!


问:
Package conventions for MVC app
Which (if either) of the below is the more conventional/acceptable way to structure packages in a J2EE app? I'm trying to follow an MVC pattern as much as possible.

foo.bar.users

foo.bar.users.servlets

foo.bar.users.DAO

foo.bar.users.Entity

foo.bar.orders

foo.bar.orders.servlets

foo.bar.orders.DAO

etc...

or

foo.bar.DAO

foo.bar.DAO.users

foo.bar.DAO.orders

...

foo.bar.servlets

foo.bar.servlets.users

foo.bar.servlets.orders

...

答: I prefer the second option, for me it have more sense to store package as the architeture model (MVC) and not favour an arrangement based on your specific application logic.</p>

Title: Package conventions for MVC app


问:
exclamation points in error messages
What do you think about using exclamation points in error messages?  i.e. "The address is not valid!".

Personally, I think it adds nothing, insults the user, and makes the product look like it was written in TRS-80 BASIC by a 12-year-old.

答: I LIKE BOLD, ALL CAPS, AND EXCLAMATIONS!

Title: exclamation points in error messages


问:
Designing class methods: self contained or explicit calls?
I'm probably butchering the terms, if someone knows the appropriate terms - that'd be great.

But my question is: should I design my classes so that their methods' parameters be accessible from the outside, or should they be all self contained?

For example, I want to set a domain name for a class, which will served as the 'active' domain:

```<code>function setDomain($url){
        if ($this -> domainUrl = parse_url($url, PHP_URL_HOST)){
            $this-> domain = $this->db->get_where('domains', array('host' => $this->domainUrl));

            return $this;
        }

        return false;
    }
</code>```

and then go the route of:

```<code>function addDomain(){
        $query = "INSERT INTO domains (host) VALUES ('$this->domainUrl')";
        $this->db->query($query);
        return $this
    }
</code>```

or I can abandon the entire route of setDomain(), and than just call the url explicitly, such as:

```<code>function addDomain($url){
        $query = "INSERT INTO domains (host) VALUES ('$url')";
        $this->db->query($query);
    }
</code>```

Which would you say is preferable and I guess - what is that dependent upon, because there might be cases where I'll need to call it explicitly.

答:
Generally only set attributes on the instance if:

you will be making many calls with those exact arguments,

the parameters need to be collected from various places for final processing, or

there is so many arguments that you need to name them.

Otherwise passing an argument is less code and less code is more readable. Also the compiler/interpreter will tell you when you missed argument, while you have to check yourself when you forgot to call a setter.


问:
Why isn't Lisp more widespread?
I am starting to learn Scheme by the SICP videos, and I would like to move to Common Lisp next.

The language seems very interesting, and most of the people writings books on it advocate that it has unequaled expressive power. CL seems to have a decent standard library.

Why is not Lisp more widespread? If it is really that powerful, people should be using it all over, but instead it is nearly impossible to find, say, Lisp job advertisements.

I hope it is not just the parenthesis, as they are not a great problem after a little while.

答: For web development with Lisp dialects, there can be a bit of a chicken-and-egg problem - because few people use Lisp, hosts either don't allow it or don't make it easy, and because it's not easy, few people use it.  But actually, getting Lisp running on a host can be easier than you might think, even if it requires a bit more work than their out-of-the-box PHP service does.  I recently got guile Scheme apps working here with just a little effort.</p>

Title: Why isn't Lisp more widespread?


问:
Using Map in Java (or other strongly-typed languages) to work with unstructured data
After looking at the core data type for frameworks that deal with unstructured data in java:

json java library: JsonObject

Mongodb java api: BasicBSONObject

SolrJ (Solr java client): SolrDocument

the common theme seems to be that data are first de-serialized into Map, then transformed into an given class by reflection.

So this raises the question, why not just work with these Map (or sub-type of map) directly? You can extend Map and create your own sub-type, and you will still have all the benefit of OO programming.

Edit
I am not concerned with the cost of deserialization, but the flexibility that Map offers when dealing with unstructured data.  By this, I mean not having to define a class that the data can be deserialized into.

Edit 2
I am more interested in the "why not (disadvantages)", since the framework I mentioned already demonstrated that it could be done.

答:
... why not just work with these Map (or sub-type of map) directly? You can extend Map and create your own sub-type, and you will still have all the benefit of OO programming.

Good question.  Why indeed?  In dynamic OO languages (e.g. Ruby, LUA, Javascript, Python, Perl, and others) every object is basically just a map.  You can add new properties and methods to objects at run-time.  It's very powerful, but you give up compile-time validation of method calls.  It's just not the Java way.


答:
The convenience of working with a strongly typed object sometimes outweighs the cost of serializing to/from that object. For instance I usually use JSON to transmit MVVM ViewModels over the wire. Once the data is deserialized, I can take advantage of the functionality embedded in the ViewModel class that works on the data. If I were just passing around dumb data, then I agree it probably makes sense to forgo that extra step.

What is dumb data? To me dumb data is a class that has nothing on it but simple properties/fields and any logic is provided by other classes that consume them (cf. Anemic Domain Model or Data Transfer Object).

If instead you are (de)serializing intelligent objects (like my ViewModel example), there is much more to gain. This goes beyond just validation. If you look at the argument for Rich Domain Models versus Anemic Domain Models, the case is that we are putting the logic that operates on the data with the data itself. That's the entire point of using an Object Oriented language. Presumably you're passing the data around to have some function performed on it. Serialize it into a rich object and put the function on that object so all you have to do is invoke the function. I've touched on the idea in a blog post here.

Title: Using Map in Java (or other strongly-typed languages) to work with unstructured data

Body:
After looking at the core data type for frameworks that deal with unstructured data in java:

json java library: JsonObject

Mongodb java api: BasicBSONObject

SolrJ (Solr java client): SolrDocument

the common theme seems to be that data are first de-serialized into Map, then transformed into an given class by reflection.

So this raises the question, why not just work with these Map (or sub-type of map) directly? You can extend Map and create your own sub-type, and you will still have all the benefit of OO programming.

Edit
I am not concerned with the cost of deserialization, but the flexibility that Map offers when dealing with unstructured data.  By this, I mean not having to define a class that the data can be deserialized into.

Edit 2
I am more interested in the "why not (disadvantages)", since the framework I mentioned already demonstrated that it could be done.


问:
Sprint planning and accommodating slack
After reading Tom DeMarco's Slack, I'm wondering how to factor slack into sprints.

For those who haven't read the book, TDM describes 'slack' as providing time for innovation and other good things.

Scrum leans towards eliminating slack and resisting change within the sprint. Allowing stories to be re-prioritised between sprints. I appreciate the purpose of a sprint, and am not trying to ask how to respond to change within them.

My initial thought about adding slack to sprints would be to plan a sprint with 8/9 days of work for a two week sprint. If you're conscious of this decision, can still calculate your velocity accurately? Based on story points completed in your 8/9 day window (vs 10).

Conversely, these are two competing ideas and don't belong together... ?

gnat's focus factor link is interesting.

答:
In Agile Estimating and Planning Mike Cohn talks about slacking in a round about way by describing the difference between "ideal time" and "elapsed time":

Ideal time is the amount of time that something takes when stripped of peripheral activities.

Elapsed time [...] is the amount of time that passes on a clock.

More examples of why ideal time does not equal elapsed time are:

Supporting the current release

Sick time

Meetings

...Phone calls

...Email [your friends]

...Task switching

One piece of advice he gives is to estimate based on ideal time, per user story.

Title: Sprint planning and accommodating slack


问:
Problem and Requirements Definition
I was recently hired to redesign a management system from scratch. This is my first  business-scale project. I have assisted with business applications in the past, but I am the only one dedicated to redesigning and programming the system with the assistance of a company employee. This employee built the previous version of the management system.

We all agree that we want this done, and done right.  I am willing to put in the time upfront to define the problem and requirements so I do not have to reap bad seeds during testing.

At the moment, I am trying to capture the problem and gather the requirements for this management system. What questions should I ask this employee to be able to move forward with some documentation? I realize these requirements can change constantly, but I would like a starting point to work with.

Here are a few questions I have come up with:

What is the purpose of the management system?

  What is the problem we are trying to solve?

  What will be the features of this system?

  Who will be using the system? (Employees? Outside Entities?)

  What are the means of security for this system? (Can an outside entity see what an employee can see? etc.)

答: Ask the employee that built the system about what challenges they were faced with when designing and building the system. You may very well face the same challenges, so you might as well learn something from their experience.</p>

Title: Problem and Requirements Definition


问:
Tips for debugging with very little info?
I've inherited a project with a fairly large codebase, and the original developer rarely, if ever, replies to emails. There's a ton of different ways to do some things in it, and I don't know all of them. A lot of duplicated code along these paths (rather than functions included by, say, 5 pages that do relatively the same thing, it's code copied across 5 pages), and some subtle issues in the database (we've all heard of spaghetti code, but have you ever heard of a spaghetti database?)

All of this I can deal with most of the time no problem.

The issue is when a client finds a bug somewhere. They'll usually send a screenshot of the ending issue, and say, "Could you take a look at this?" while highlighting the specific thing on the page that's wrong, and sometimes what was expected. Very little more information is given, and trying to talk to them and get more (such as what they did to get the result) is like pulling teeth.

Basically, it boils down to this:

Large and complex code base I'm not 100% familiar with

Many many ways things can go wrong

Very little information on how a bug came to be

Does anybody have any tips, tricks, suggestions, etc. on how to debug this sort of thing?

答:
My most earnest advise is to start refactoring where you can.  I can not count the number of times I saw a recopy of functionality only to find out that it wasn't 100% a full copy.  It was 99.9% copy and 1 small, minor mistake which resulted in a bug.  Start adding unit tests to everything and if you have a QA department try to get some automated testing scripts going for those portions of the code you're working.

On the other hand, see how much logging to can inject into the code.  That is, if it doesn't have much in the way of logging you can add a flag to the code to start picking up more verbose logging for your own debugging purposes.  This is something you can have a user turn on and off if you can get a dialog going.  It's helped me more times than I can count.  I normally get "it doesn't work" without a picture of the problem.  I just say "send me the log file."


答:
Since this is a rewrite the first thing you need to establish is why is this being rewritten. from there you can build with more questions depending on the reason why it's being rewritten. Most of the questions you listed should already be answered in existing documentation or as part of why they want a new system.

If it's being rewritten because support for the language no longer exists or the source code is unmaintainable. in cases like this the major requirement is usually that its hard/impossible to tell that it is a different program from the end user perspective.

If the system is being rewritten because it no longer meets the needs of the business then, you are going to have a different set of questions to determine what parts need adding/fixing.

Title: Problem and Requirements Definition

Body:
I was recently hired to redesign a management system from scratch. This is my first  business-scale project. I have assisted with business applications in the past, but I am the only one dedicated to redesigning and programming the system with the assistance of a company employee. This employee built the previous version of the management system.

We all agree that we want this done, and done right.  I am willing to put in the time upfront to define the problem and requirements so I do not have to reap bad seeds during testing.

At the moment, I am trying to capture the problem and gather the requirements for this management system. What questions should I ask this employee to be able to move forward with some documentation? I realize these requirements can change constantly, but I would like a starting point to work with.

Here are a few questions I have come up with:

What is the purpose of the management system?

  What is the problem we are trying to solve?

  What will be the features of this system?

  Who will be using the system? (Employees? Outside Entities?)

  What are the means of security for this system? (Can an outside entity see what an employee can see? etc.)


问:
Are there any statistics that show the popularity of Git versus SVN?
I'm writing an essay, and would like to have some empiric evidence, perhaps longitudinal data where the popularity of these technologies is compared over a period of some years.

Are there any statistics that show the popularity of Git versus SVN?

答:
I think ohloh has some relevance, but I am not sure you could pry historical data from them.

Also for some specific domain, see use of vcs for Debian packagin (you could be able to pry some historical data from UDD, but probably not very long, as the Vcs-* fields are not that old).


答:
It's hard to debug in production try running locally. I use Debug Viewer in conjunction with a profiler.

I would recommend ANTS, not sure if it's free right now. I used a 30 day demo version and it will give a detailed analysis when you run the application with list of susceptible parts which you can actually break down into for finding out the specific cause. I think there are plenty of free profilers available too. I found it very difficult to debug WPF leaks than conventional winform leaks.

Hope it ain't a WPF. Good luck though.


问:
(Why) Should I learn a new programming language?
I'm quite proficient with Java, C/C++, JavaScript/jQuery and decently good at Objective-C. I'm quite productive with the languages and their corresponding frameworks too and do produce enterprise level systems (and also small scale ones) with sufficient ease all the while keeping code 'clean' and maintainable (yes, I can read my own code after six months :)

Unless mandated by the platform (iPhone, iPad, etc.) or by the client/implementation organization, just "why" should I learn a new programming language? Just for "fun"? And do what with that fun if I'm not going to do anything worthwhile with it?

A lot of my peers are ready to dive in to learn the "next new thing/language" and it's usually Python, Ruby or PHP (just naming a few popular ones). Now, just knowing the language by itself is futile IMHO. You also need to know the frameworks, learn their usage/APIs as well as 'good implementation practices', etc.

So from an 'economic' sense, is there any benefit in learning a new programming language? If the language is learned in a quick and dirty fashion, it'll probably also be used for quick and dirty prototyping/implementation - but I don't see THAT as a justifiable investment of time/effort.

So just WHY should I (or anyone for that matter) learn a new programming language other than "it's fun so let's try it out" - if the investment of time may not be worth it in the long run?

答:
Each one of us decides on what we want to work on so...

you learn it because you want to

you learn it because you need it for the job that you want

If you don't want to learn PHP, no one is making you and there's a ton of areas where you can program without ever knowing even how to spell PHP.

A lot of people look at the job market to see where hot areas area and jump on those technologies. A lot of people learn one language and stick with it and 20 years later they become legacy maintenance engineers.  And then you have a lot of people who are anywhere between these two extremes.

In the end, it is all about what where you want to be.


答:
From The Pragmatic Programmer, Tip #8 "Invest Regularly in Your Knowledge Portfolio":

Learn at least one new language every year. Different languages
  solve the same problems in different ways. By learning several different
  approaches, you can help broaden your thinking and avoid
  getting stuck in a rut. Additionally, learning many languages is far
  easier now, thanks to the wealth of freely available software on the
  Internet

It's not about the next "new thing".  It's about thinking in different ways outside of your normal thought patterns.

There is a saying, "When you're a hammer, everything looks like a nail".  Maybe there is a better way to solve a problem using some other technology.  If you don't explore, you may not know that it was available.

Title: (Why) Should I learn a new programming language?

Body:
I'm quite proficient with Java, C/C++, JavaScript/jQuery and decently good at Objective-C. I'm quite productive with the languages and their corresponding frameworks too and do produce enterprise level systems (and also small scale ones) with sufficient ease all the while keeping code 'clean' and maintainable (yes, I can read my own code after six months :)

Unless mandated by the platform (iPhone, iPad, etc.) or by the client/implementation organization, just "why" should I learn a new programming language? Just for "fun"? And do what with that fun if I'm not going to do anything worthwhile with it?

A lot of my peers are ready to dive in to learn the "next new thing/language" and it's usually Python, Ruby or PHP (just naming a few popular ones). Now, just knowing the language by itself is futile IMHO. You also need to know the frameworks, learn their usage/APIs as well as 'good implementation practices', etc.

So from an 'economic' sense, is there any benefit in learning a new programming language? If the language is learned in a quick and dirty fashion, it'll probably also be used for quick and dirty prototyping/implementation - but I don't see THAT as a justifiable investment of time/effort.

So just WHY should I (or anyone for that matter) learn a new programming language other than "it's fun so let's try it out" - if the investment of time may not be worth it in the long run?


答:
There are several reasons why learning a new language may be worth an investment in time:

Increase the size of one's tool box - learning a new language can provide additional paths to solving technical issues. The possibility of new tools could provide a better choice of language/platform for solving certain problems than the tools/languages that one previously knew. A simplistic example might be that of a programmer who only knows C. Learning a scripting language opens up other possibilities for him/her - in terms of deployment, environment set up, etc.

Gain access to a new platform - an excellent example might be Objective C - if one wants to develop for iOS, learning this language is almost mandatory.

Learn new paradigms - certain languages might have better access to newer paradigms. Using C as an example, it might be difficult to develop web services in standard ANSI C. However, learning to develop in .NET, Java, PHP, or other new languages might speed development of web services.

Learning new languages can provide immediate benefits, as you've already noted, in "quick and dirty" solutions. However, these immediate solutions might lead a programmer to investigate and dig deeper into the architecture associated with the new language to "properly" learn it. One can view these quick learning exercises as an investment into the investigation of whether a new language is worth addition training time.


答:
Not only do you want to learn new languages you want to learn languages that are different from the ones you know already If you know Java learning C# will not really challenge you, they are fairly similar. Ideally you should pick a language that is very different from what you know. If you know java, JavaScript and Objective-C you want something very different

Such as:

Ruby a fun weakly typed OO Language

Prolog A logic programming language very different

Erlang Concurrency and Fault Tolerance done very well

Scheme Go read SICP and reach enlightenment

Haskell One of the most powerful type systems in the world if it compiles it will probably work, also will keep you from making all sorts of strange errors and lot more.

Or just pick up Seven Languages in Seven weeks which will do about what the title says it will.


答:
We think with words. The language we use influences the way we do it. There's an interesting case about Pirahã language - people speaking that language can't handle as something apparently "simple" or "intuitive" as numbers because the language they have been brought up in has no words for "specific quantities" (not even "one" and "many").

With programming languages is the same. A new programming language, can "open up" your mind to some aspects of programming.

Given your current programming background, I recommend you to learn some functional language, like Erlang or Scala. Finally, Clojure is a very solid language, too.

If you want to feel a bit more at home first, try a powerful scripting language like Python or Ruby.


答:
Why do people climb Mt. Everest? Or run 100 Miles in 24 hours? Why do we undertake any challenge? Because it's there. I see nothing wrong with "Ars gratia artis". There comes a point where learning for learning's sake becomes it's own reward. But if you want more powerful reasons to learn a new language here are some:

New ways to solve problems
Learning a new language, really taking the time to dive in, gives you the chance to program again as a newbie. That new perspective can teach you techniques that might carry over to an old language. Think of the influence Ruby on Rails had on ASP.NET MVC or how Java Hibernate was ported to C# (along with countless other frameworks that influence .NET development). Exposure to different languages can teach you new ways to address problems.

The right tool for the right job
All of the languages you mentioned are OO/Procedural hybrids (or purely procedural in the case of C). Try your hand at a Functional language or two. Try implementing factorial in Erlang using recursion and watch your jaw hit the floor when 20000! returns in 5 seconds (no stack overflow in site). Then look at the power of scaling your application to crunch through numbers and parse protocols with less code and in less time than it would take to get two instances of a JVM talking through RMI or SOAP. Learning other languages/frameworks that are targeted to solve specific problems will give you more tools.

Meet new people/expand your network
Diving into a new language exposes you to a new community. Meeting new people is a good thing for your career and personally.

New opportunities
Knowing a new language can only increase your chance of getting that job with that hot startup. "Man this job would be perfect if I knew Ruby." Besides, you might enjoy the language enough that you decide to switch paths.

Keep it fresh
Working with the same thing day in day out becomes tedious. Using a different language can give you a break from the daily grind and allow you to come to the next day refreshed.

Because it's there Learn a new language because you want to.


答:
As with any general design question, the answer to this question is also it depends. It all depends on your abstraction for the class.

Let me give two examples that illustrate two different abstractions:

 class DomainOperator: This highly fictitious class takes care of performing various operations on a domain. Given a domain, it can store it, make some String-relevant operations on it, etc... For this class, I would go declaring the domainURL as an instance variable. Multiple methods should be making use of it; it acts as a global within a class.

 class WebSite: Yet another made-up class that is responsible for storing the properties of a web-site; domain is one of these properties. It has a method called addDomain(url) and in this method, it stores the domain.

I am not too happy with these examples, but the point is that it depends on what you want to do with your class. If your class logic is based on a domain, then I would make it an instance variable. If not, a parameter would be fine.

Side note: These small decisions become easier with refactoring. If you look at a class and you see 4 methods (out of 7) using a variable, then it might be time to extract these 4 methods out into a new class; making the shared variable an instance variable of the new class.

Title: Designing class methods: self contained or explicit calls?

Body:
I'm probably butchering the terms, if someone knows the appropriate terms - that'd be great.

But my question is: should I design my classes so that their methods' parameters be accessible from the outside, or should they be all self contained?

For example, I want to set a domain name for a class, which will served as the 'active' domain:

```<code>function setDomain($url){
        if ($this -> domainUrl = parse_url($url, PHP_URL_HOST)){
            $this-> domain = $this->db->get_where('domains', array('host' => $this->domainUrl));

            return $this;
        }

        return false;
    }
</code>```

and then go the route of:

```<code>function addDomain(){
        $query = "INSERT INTO domains (host) VALUES ('$this->domainUrl')";
        $this->db->query($query);
        return $this
    }
</code>```

or I can abandon the entire route of setDomain(), and than just call the url explicitly, such as:

```<code>function addDomain($url){
        $query = "INSERT INTO domains (host) VALUES ('$url')";
        $this->db->query($query);
    }
</code>```

Which would you say is preferable and I guess - what is that dependent upon, because there might be cases where I'll need to call it explicitly.


答:
Anyone can create a new language; but nobody seems to understand that "better" is rarely the same as "so much better that the cost of adoption is actually justified". The end result is hundreds of different languages, where it's impossible for anyone to understand all source code, and where programmers need to waste about a quarter of their time being unproductive due to language/framework/library differences.

In an ideal world, there'd be one low level programming language (e.g. C), one high level "safe" programming language (e.g. Java) and one scripting language. There'd also be a large sledge hammer for destroying the "Programming Language Tower of Babel" created by people who don't understand the virtues of standardisation and the cost of "churn" and constant retraining on the I.T. industry as a whole.

From a 'macro-economic' sense, there's nothing wrong with learning a new programming language as a hobby, but using that new programming language for anything makes you part of the problem.


问:
Choosing right technology for messaging system
I'm working on a messaging system for two years now, the system was written by a long ago gone team and involves emails and document processing. The basic process is:

Receive an email, parse it, save attachments to samba share. Notify message processor. We have a robust Java application doing this very well.

Process the message, this involves getting user data from LDAP, calling file processing web-services on different platforms. The system has a sort of re-delivery service that polls database for failed or timed out messages in different states and resends them.

The file processing parts are EJB web-services that basically run command line utilities.
The problem lies in our orchestration solution which is based on OpenESB (almost dead now), it has a bunch of BPELs calling each other and calling remote EJBs (EJB3.0 on glassfish v2).

The biggest problem is that too much logic is done in BPELs (say, all database updates are done in BPELs, there's no persistance layer), they look like the most horrifying spaghetti I've ever seen. Not to mention they make NetBeans which we're using to edit them run really slow, to the point that some files are only editable in a simple text editor as XML. Moreover the system has a number of nasty bugs that would require major refactoring to fix and I'm dreaded to even think about it. These messages are handled manually by our support stuff so there's almost no client-impact but I would like to have a real transactional system anyway.

Now, for the question itself. I'm willing to spend a lot of my own free time trying to reach two goals: build a replacement for ESB and BPELs, learn new and preferably trendy technologies. I would like to keep the code in file processing EJBs since they run just fine, although I'm thinking of getting rid of SOAP as their remote interface.
So I'm asking for any insight of which technology(-ies) would let me create a robust messaging solution that would:

Have a friendly persistence layer, there won't be anything really complex in dbs, just message meta-data.

Take care of balancing and polling calls to file processing web-services.

Wouldn't require dealing with tons of XML in different places in order to add a new interface method.

Would be scalable - run on a number of machines.

Would allow realtime monitoring, like viewing message queues, current load, statuses etc.

Hopefully will let me learn something new, meaning not J2EE stack. Basically I'm open to anything except BPEL and OpenESB.

答:
I'm having a lot of fun with Erlang right now. It's a great language in and of itself. The real fun is in the framework and runtime it sits on. The Erlang Runtime is designed for distributed, concurrent applications (it was born at Ericsson for their network infrastructure). For integration with other systems, there is RabbitMQ which is built in Erlang and has native APIs for most of the big languages. It has a built in management interface that allows you to view messages and the like.

Addressing your requirements specifically:

Erlang has a built in database called Mnesia. For durable messaging, Rabbit leverages Mnesia (if an instance goes down the queue won't go down with it) and you don't have to worry about it yourself it just works.

Out of the box Rabbit uses round robin pub-sub. If you have 3 listeners to what's called a fanout queue they will be alternated between for each message.

Rabbit has an API driven configuration with UI's available to manage it without changing programs.

Check: Erlang was built with scalability in mind...it was originally designed to support Ericsson's network infrastructure. Combined with RabbitMQ and you can distribute your message processing across many nodes

Check: Rabbit MQ has many built-in and 3rd party plugins for Monitoring

Erlang is gaining a lot of traction as a solution for concurrent processing definitely a different approach outside of the standard OO paradigm.


问:
Should QA find reproducible scenarios?
Sometimes my QA team reports bugs, but neither I or them have any idea on how to reproduce them. This leads to very long and frustrating debugging sessions which sometimes do not even yield results.

My software is tied heavily with proprietary hardware so bugs can come from many directions at once.

Should I expect more from them than "your software crashed when I pressed a button" or should I figure myself what happened?

EDIT:

One of my coworker pointed out that we are probably all developers here so the results might suffer a little bias

答:
IMO, you should.  QA aren't doing their job if they can't give you any reproduction steps.  Don't waste your time trying to reproduce something that you can't, just close it as "Cannot reproduce" and move on.

Your time is much more valuable than that.

Title: Should QA find reproducible scenarios?


答:
Yes, you should expect more from them. They should be able to say:

```
1. Started new instance of program
2. I pressed button A
3. Entered "test text" into the TEST NAME field on Form #1
4. Pressed button B
5. Observed that the program crashed with this message (see attached screenshot).
```

If all they tell is "it crashed", they're not very good. Even if the above steps are not 100% reproducible, a large enough sample of these crashes might help narrow down the cause, once a pattern is detected.

Title: Should QA find reproducible scenarios?

Body:
Sometimes my QA team reports bugs, but neither I or them have any idea on how to reproduce them. This leads to very long and frustrating debugging sessions which sometimes do not even yield results.

My software is tied heavily with proprietary hardware so bugs can come from many directions at once.

Should I expect more from them than "your software crashed when I pressed a button" or should I figure myself what happened?

EDIT:

One of my coworker pointed out that we are probably all developers here so the results might suffer a little bias

Body:
Yes, you should expect more from them. They should be able to say:

1. Started new instance of program
2. I pressed button A
3. Entered "test text" into the TEST NAME field on Form #1
4. Pressed button B
5. Observed that the program crashed with this message (see attached screenshot).

If all they tell is "it crashed", they're not very good. Even if the above steps are not 100% reproducible, a large enough sample of these crashes might help narrow down the cause, once a pattern is detected.


答:
The best argument I know is that it broadens your perspective on how many different ways a problem can be solved, or some logic can be expressed. Knowing well Java and C++ gives you a good view on both the native & VM realms, but there are much more "degrees of freedom" to explore.

I have about 15 years of experience in C++, 5 in Java. There are many languages I learned and left behind (PHP, Pascal, assembly for a bunch of different processors, among others) and can say for sure that even those I don't use anymore left a significant mark on how I think about a problem. Also: even if you want to stick with, say, Java, for a given project, you'll have to know the alternative to present good counterarguments to its proponents.

Still, I learned Python just this year, and was delighted by how elegantly some things can be done. So much that I decided to convert a handful of REST servlets I had written, from Java to Python. The advantages in code maintainability were quite significant. For sure it left a mark on my way of doing things, too, not only because I will now choose Python for some tasks, but also because I may adopt similar design principles when coding in C++ & Java.

That said, I don't think you should learn lots of different languages all the time, just for the sake of it. It takes a considerable time toll, and the "accomodations" you'll have to make in your mind for them to coexist with the others you already know also take time and effort. I only decide to learn a language when it has enough maturity, has a good developer base, and offers significantly different outcomes from the others I know or plan to learn. When I decided to learn Python, for instance, I also considered Ruby and Perl, and later discarded them - at least for the near future.


答:
QA should always try and make the bugs as easy for you to reproduce as possible and the bug description should contain the steps taken.

However, if they can't easily reproduce the bugs, they should still get entered into the bug database with suitable title/headings and a full description of what they did to cause the bug.  The bug description should clearly state that they can't reproduce the bug (perhaps with some comment along the lines of "tried it five times, it happened once").  This way, if someone else sees the same bug, they can add to the bug database with their findings and also you get as much information as possible which further down the line could be vital in saving you time tracking down the problem.

Also, you get to filter the information - there might be a lot of bugs in different systems that you know are all linked to (eg) one area of the code - if QA don't report anything (as they can't reproduce them) then this information doesn't get to you.

Title: Should QA find reproducible scenarios?


答:
It looks like your QA department is doing too much exploratory testing (ie. They don't have a good test plan).

Exploratory testing is good, and identifies problem areas, but from there they should be defining reproducible test cases (ie. a test plan) to perform that will reveal specific bugs.

There's a number of reasons why a correct repro is necessary (not just good, but necessary):

You have to repro so that you can debug/track down the cause.

QA will need to be able to verify the fix once you're done.

Further test passes will need to do regressions on previous bugs.

Known bugs can be discarded if the exposure is too small or repro is too unlikely.

So, as SteveCzetty notes: Close it as no repro and get back to work.

Title: Should QA find reproducible scenarios?


答:
For the remote interface I'd recommend considering RESTful instead of SOAP. I myself had bad experiences with SOAP in the past (particularly regarding performance and interoperability), and found REST a great replacement: lightweight and flexible.

For the ESB infrastructure your needs require a framework, to support the features mentioned it'd be burdensome to do otherwise. I don't have much experience on it, but one of my customers runs a quite complex ESB using Mule, with good results.

An alternative to ESB would be to use just an MQ framework. For instance, OpenMQ

Title: Choosing right technology for messaging system

Body:
I'm working on a messaging system for two years now, the system was written by a long ago gone team and involves emails and document processing. The basic process is:

Receive an email, parse it, save attachments to samba share. Notify message processor. We have a robust Java application doing this very well.

Process the message, this involves getting user data from LDAP, calling file processing web-services on different platforms. The system has a sort of re-delivery service that polls database for failed or timed out messages in different states and resends them.

The file processing parts are EJB web-services that basically run command line utilities.
The problem lies in our orchestration solution which is based on OpenESB (almost dead now), it has a bunch of BPELs calling each other and calling remote EJBs (EJB3.0 on glassfish v2).

The biggest problem is that too much logic is done in BPELs (say, all database updates are done in BPELs, there's no persistance layer), they look like the most horrifying spaghetti I've ever seen. Not to mention they make NetBeans which we're using to edit them run really slow, to the point that some files are only editable in a simple text editor as XML. Moreover the system has a number of nasty bugs that would require major refactoring to fix and I'm dreaded to even think about it. These messages are handled manually by our support stuff so there's almost no client-impact but I would like to have a real transactional system anyway.

Now, for the question itself. I'm willing to spend a lot of my own free time trying to reach two goals: build a replacement for ESB and BPELs, learn new and preferably trendy technologies. I would like to keep the code in file processing EJBs since they run just fine, although I'm thinking of getting rid of SOAP as their remote interface.
So I'm asking for any insight of which technology(-ies) would let me create a robust messaging solution that would:

Have a friendly persistence layer, there won't be anything really complex in dbs, just message meta-data.

Take care of balancing and polling calls to file processing web-services.

Wouldn't require dealing with tons of XML in different places in order to add a new interface method.

Would be scalable - run on a number of machines.

Would allow realtime monitoring, like viewing message queues, current load, statuses etc.

Hopefully will let me learn something new, meaning not J2EE stack. Basically I'm open to anything except BPEL and OpenESB.


答:
At this point in your career, you should learn new languages if you think they will make you a better programmer.

Most of your listed languages (Java/C/C++/Javascript/Objective-C) are conventional OO/imperative.  Learning yet another OO/imperative language will probably not teach you much more about that kind of programming.  Unless you have a particular interest, there is no point in learning the flavor-of-the-month on spec.

I am also inclined to be skeptical about claims to order-of-magnitude productivity increases.  However, it might be worthwhile to check out the occasional reputed high-productivity language, to see if you like it.

The best reason to learn a new language is to learn skills of general applicability.  For that, I would recommend a deep dive into a functional language (Haskell, or one of the Lisps) on one hand, and assembly code and systems architecture (x86 or ARM) on the other.

Functional programming will break your brain and improve your mind, while learning machine architecture will improve your debugging and optimization abilities, even if you never write another line of assembly.


答:
Your question is such a leading one that it begs me to ask the following question:

If you are programmer by profession, why in the world wouldn't you want to learn something new to add to your professional experience?

Your question sounds to me a lot like the attitude of a student I once had. A year or two before Y2K I was teaching a Cobol class (as an elective), at the request of the Director of Career Services at the university where I was teaching at the time. He had so many companies approaching him with job opportunities for Cobol programmers that he thought we would be doing our students a disservice by not giving them the opportunity to learn the skill and add to their skill set.

I had a student who took the class as his last elective class to graduate. He was also working as a C Programmer at the time. He took the Cobol class because he had no other choices and he wanted the degree. So he came to the class with a chip on his shoulder.

I already know C, and I'm using it professionally so I don't know why in the world that anyone would want or even need to learn Cobol.

So I challenged him with the task of writing a program to read data from a file that had a specific format for each record of input (ie how many characters each field took up on a line, which field came first, second, third, etc.)

He was to write his program in C, which he did, and he showed off his program to me. At the same time, I showed him my Cobol version of the program.

Then I threw him a curve ball:

Supposed that the end user is getting data from somewhere else. It's the same fields in each record, but the order and the number of characters per field is different. Show me what you would have to change in your program to make it work with the new data format.

He took a day to make a new version of the program that worked with the new data format. It involved changing at least 20 or 30 lines of code, and modifying several functions and modules.

Then I showed him the changes I needed to make to my Cobol program. I modified the picture clause to reflect the new data format.

I'm not sure he completely understood the lesson of that exercise, but he at least quit complaining for the rest of the semester.

So - in answer to your question:
You should learn new languages because you want to LEARN. And if you don't want to learn - more power to you... (I'm just not sure I would hire you with that attitude)


问:
When is it not appropriate to use the dependency injection pattern?
Since learning (and loving) automated testing I have found myself using the dependency injection pattern in almost every project. Is it always appropriate to use this pattern when working with automated testing? Are there any situations were you should avoid using dependency injection?</p>

答:
Basically, dependency injection makes some (usually but not always valid) assumptions about the nature of your objects. If those are wrong, DI may not be the best solution:

First, most basically, DI assumes that tight coupling of object implementations is ALWAYS bad. This is the essence of the Dependency Inversion Principle: "a dependency should never be made upon a concretion; only upon an abstraction".

This closes the dependent object to change based on a change to the concrete implementation; a class depending upon ConsoleWriter specifically will need to change if output needs to go to a file instead, but if the class were dependent only on an IWriter exposing a Write() method, we can replace the ConsoleWriter currently being used with a FileWriter and our dependent class wouldn't know the difference (Liskhov Substitution Principle).

However, a design can NEVER be closed to all types of change; if the design of the IWriter interface itself changes, to add a parameter to Write(), an extra code object (the IWriter interface) must now be changed, on top of the implementation object/method and its usage(s). If changes in the actual interface are more likely than changes to the implementation of said interface, loose coupling (and DI-ing loosely-coupled dependencies) can cause more problems than it solves.

Second, and corollary, DI assumes that the dependent class is NEVER a good place to create a dependency. This goes to the Single Responsibility Principle; if you have code which creates a dependency and also uses it, then there are two reasons the dependent class may have to change (a change to the usage OR the implementation), violating SRP.

However, again, adding layers of indirection for DI can be a solution to a problem that doesn't exist; if it is logical to encapsulate logic in a dependency, but that logic is the only such implementation of a dependency, then it is more painful to code the loosely-coupled resolution of the dependency (injection, service location, factory) than it would be to just use new and forget about it.

Lastly, DI by its nature centralizes knowledge of all dependencies AND their implementations. This increases the number of references that the assembly which performs the injection must have, and in most cases does NOT reduce the number of references required by actual dependent classes' assemblies.

SOMETHING, SOMEWHERE, must have knowledge of the dependent, the dependency interface, and the dependency implementation in order to "connect the dots" and satisfy that dependency. DI tends to place all that knowledge at a very high level, either in an IoC container, or in the code that creates "main" objects such as the main form or Controller which must hydrate (or provide factory methods for) the dependencies. This can put a lot of necessarily tightly-coupled code and a lot of assembly references at high levels of your app, which only needs this knowledge in order to "hide" it from the actual dependent classes (which from a very basic perspective is the best place to have this knowledge; where it's used).

It also normally doesn't remove said references from lower down in code; a dependent must still reference the library containing the interface for its dependency, which is in one of three places:

all in a single "Interfaces" assembly that becomes very application-centric,

each one alongside the primary implementation(s), removing the advantage of not having to recompile dependents when dependencies change, or

one or two apiece in highly-cohesive assemblies, which bloats the assembly count, dramatically increases "full build" times and decreases application performance.

All of this, again to solve a problem in places where there may be none.


问:
What's the difference between junior, middle, and senior developers?

Possible Duplicate:

  Whats the difference between Entry Level/Jr/Sr developers?

There seems to be three common java programmer qualification levels:

Junior

Middle

Senior

What makes a programmer  "junior", "middle", or "senior"? Does it mean the the programmer has a specific amount of certifications or job expertise? How do IT companies decide what title to give to a programmer?

答:
There will be as many answers to this question as there are programmers. But I judge them this way:

A Junior developer will need near-constant help. Not only will they not know the business domain, but they may also struggle with the fundamentals of the language or the toolset. They don't know what they don't know, so without guidance, they will make frequent mistakes which, if not kept on top of, will derail the wider team.

A regular Developer has some experience under their belt. They will be independently productive and will be able to tackle most tasks on their own, or understand when they need to reach out for help.

A Senior Developer has even more experience and will be able to design solutions as well as completing tasks. However, they may need their proposed designs vetted before they start to implement, as they won't necessarily have an overall architectural vision. They will be able to mentor more junior members of the team.

But you should really head over to this much better answer to see what I ought to have written!


答: If the bug can't be reproduced consistently, how will QA ever know whether it was fixed?</p>

Title: Should QA find reproducible scenarios?


答:
You could tie it to the programmer's competency matrix if you want to make it a "harder" metric. Titles are not set in stone; it's all HR speak. Convenient buzzwords to encapsulate characteristics that may not even be precisely defined if they are defined at all.

To tie it to the PCM:

Junior Developer: Rates at least an n^2 in most disciplines. Could rate n or log(n) in a few and can have a few 2^n and still be okay.

Middle Developer: Majority n with a minority of n^2 and as few 2^n as possible. As many log(n)s as possible but will likely still be a minority.

Senior Developer: Majority n with a strong minority or even slight majority in log(n) and as few n^2 and no 2^n.

Legendary: Log(n) in everything possible with a few ns and nothing below that mark.

Specialist: Log(n) in their specializations and experience appropriate otherwise.

Obviously these would be "ideals" for each category. I doubt there are many that would fit the title who would truly measure fully to the standards.

Title: What's the difference between junior, middle, and senior developers?

Body:
Possible Duplicate:

  Whats the difference between Entry Level/Jr/Sr developers?

There seems to be three common java programmer qualification levels:

Junior

Middle

Senior

What makes a programmer  "junior", "middle", or "senior"? Does it mean the the programmer has a specific amount of certifications or job expertise? How do IT companies decide what title to give to a programmer?


答:
I wish there was a shortcut in here for referencing the Dreyfus Model of Skills Acquisition. I'd say my concepts of Junior Middle and Senior map well to the five stages if you think of each level as a range:

Anyone in the Novice or Advanced Beginner stage I would consider Junior.

Competent developers are Middle

Proficient and Expert would be Senior.

Of course the trick comes in metaknowledge. It's difficult for a person to recognize that someone knows more than he knows. If as a novice developer, I'm assessing another developer's knowledge, I wouldn't be able to assess them as anything more than a Novice (if I could assess them as higher than novice by definition I have enough knowledge to be above novice myself). The other end of the spectrum, it's difficult to assess someone with significantly less skill apropriately. Think of an expert assessing a competent developer. It's easy to say oh well he doesn't understand how to do X...he's obviously a novice.

The only solution is to have people of multiple skill levels assess an individual. At each level, you'll identify that the person is either as competent as me or not. The highest level that you get a positive would be the most accurate assessment. Now there's the problem of how to assess your existing employees ;)


答: QA should be able to reproduce the bugs based on the steps entered. If they tried hard , still could not reproduce, they should still enter the bugs with as much as details they have with the timestamp so that the developers can take a look at the application and debug logs for more details.</p>

Title: Should QA find reproducible scenarios?


问:
How serious is losing the source code?
If a software company loses the source code to one of the products they are selling, how serious would that be, in terms you could explain to a layman?  Would the term "gross negligence" be too strong?  Or "gross incompetence"?  Obviously no one got killed but isn't it as serious as some financial negligence that people get jail time for?

EDIT:
Let's say it's not a case of a disk drive crashing, natural disaster or anything like that.  Just they misplaced it.

答:
Let's say MS loses the source for Windows Phone 7... people have been killed for waaaaay less than the estimated $400 million it cost to develop it.

Depending on the product, there isn't a term that I can think of that is 'too strong'.

Title: How serious is losing the source code?


答:
A lot of bugs aren't reproducible until you know how to fix them.  That doesn't mean they don't need to be fixed.  I fixed a bug last year that I still don't know how to reproduce.  It requires some bizarre combination of a precisely-timed transmission error together with very specific garbage data in a certain memory location on the stack.  Unfortunately, one of our customers is "lucky" enough to get into that condition all the time.

So, by all means encourage QA to include reproducability steps where possible, but don't fault them if they can't.  Sometimes it will help you know where to add logging.  Sometimes all it does is tell you what doesn't cause the bug, but a bug report is always useful.

Title: Should QA find reproducible scenarios?


答:
When you don't stand to gain anything by making your project maintainable and testable.

Seriously, I love IoC and DI in general, and I'd say that 98% of the time I will use that pattern without fail. It's especially important in a multi-user environment, where you code can be reused again and again by different team members and different projects, as it separates logic from implementation. Logging is a prime example of this, an ILog interface injected into a class is a thousand times more maintainable than simply plugging in your logging framework-du-jour, as you have no guarantee another project will use the same logging framework (if it uses one at all!).

However, there are times when it is not an applicable pattern. For example, functional entry points that are implemented in a static context by a non-overridable initialiser (WebMethods, I'm looking at you, but your Main() method in your Program class is another example) simply cannot have dependencies injected at initialisation time. I'd also go as far as to say that a prototype, or any throw-away investigative piece of code, is also a bad candidate; the benefits of DI are pretty much mid-to-long-term benefits (testability and maintainability), if you are certain that you will throw away the majority of a piece of code within a week or so I would say you gain nothing by isolating dependencies, just spend the time you'd normally spend testing and isolating dependencies getting the code working.

All in all, it's sensible to take a pragmatic approach to any methodology or pattern, as nothing is applicable 100% of the time.

One thing to note is your comment about automated testing: my definition of this is automated functional tests, for example scripted selenium tests if you are in a web context. These are generally completely black-box tests, with no need to know about the inner workings of the code. If you were referring to Unit- or Integration-tests I'd say that the DI pattern is almost always applicable to any project that heavily relies on that kind of white-box testing, since, for example, it allows you to test things like methods that touch the DB without any need for a DB to be present.

Title: When is it not appropriate to use the dependency injection pattern?

Body: Since learning (and loving) automated testing I have found myself using the dependency injection pattern in almost every project. Is it always appropriate to use this pattern when working with automated testing? Are there any situations were you should avoid using dependency injection?</p>