答:
I remember having a similar argument with my lecturer when learning C++ at university. I just couldn't see the point of using getters and setters when I could make a variable public.  I understand better now with years of experience and I've learned a better reason than simply saying "to maintain encapsulation".

By defining the getters and setters, you will provide a consistent interface so that if you should wish to change your implementation, you're less likely to break dependent code. This is especially important when you classes are exposed via an API and used in other apps or by 3rd parties.  So what about the stuff that goes into the getter or setter?

Getters are generally better off implemented as a simple dumbed-down passthrough for access to a value because this makes their behaviour predictable. I say generally, because I've seen cases where getters have been used to access values manipulated by calculation or even by conditional code. Generally not so good if you are creating visual components for use at design time, but seemingly handy at run time. There's no real difference however between this and using a simple method, except that when you use a method, you are generally more likely to name a method more appropriately so that the functionality of the "getter" is more apparent when reading the code.

Compare the following:

```<code>int aValue = MyClass.Value;
</code>```

and

```<code>int aValue = MyClass.CalculateValue();
</code>```

The second option makes it clear that the value is being calculated, whereas the first example tells you that you are simply returning a value without knowing anything about the value itself.

You could perhaps argue that the following would be clearer:

```<code>int aValue = MyClass.CalculatedValue;
</code>```

The problem however is that you are assuming that the value has already been manipulated elsewhere.  So in the case of a getter, while you may wish to assume that something else might be going on when you are returning a value, it is difficult to make such things clear in the context of a property, and property names should never contain verbs otherwise it makes it difficult to understand at a glance whether the name used should be decorated with parentheses when accessed.

Setters are a slightly different case however.  It is entirely appropriate that a setter provide some additional processing in order to validate the data being submitted to a property, throwing an exception if setting a value would violate the defined boundaries of the property. The problem that some developers have with adding processing to setters however is that there is always a temptation to have the setter do a little more, such as perform a calculation or a manipulation of the data in some manner.  This is where you can get side-effects that can in some cases be either unpredictable or undesirable.

In the case of setters I'm always apply a simple rule of thumb, which is to do as little as possible to the data.  For example, I will usually allow either boundary testing, and rounding so that I can both raise exceptions if appropriate, or avoid unnecessary exceptions where they can be sensibly avoided.  Floating point properties are a good example where you might wish to round excessive decimal places to avoid raising an exception, while still allowing in range values to be entered with a few additional decimal places.

If you apply some sort of manipulation of the setter input, you have the same problem as with the getter, that it is difficult to allow others to know what the setter is doing by simply naming it. For example:

```<code>MyClass.Value = 12345;
</code>```

Does this tell you anything about what is going to happen to the value when it is given to the setter?

How about:

```<code>MyClass.RoundValueToNearestThousand(12345);
</code>```

The second example tells you exactly what is going to happen to your data, while the first won't let you know if you value is going to be arbitrarily modified. When reading code, the second example will be much clearer in it's purpose and function.

Am I right that this would completely defeat the purpose of having
  getters and setters in the first place and validation and other logic
  (without strange side-effects of course) should be allowed?

Having getters and setters isn't about encapsulation for the sake of "purity", but about encapsulating in order to allow code to be easily refactored without risking a change to the class's interface which would otherwise break the class's compatibility with calling code. Validation is entirely appropriate in a setter, however there is a small risk is that a change to the validation could break compatibility with calling code if the calling code relies on the validation occurring in a particular way.  This is a generally rare and relatively low-risk situation, but it should be noted for the sake of completeness.

When should validation happen?

Validation should happen within the context of the setter prior to actually setting the value. This ensures that if an exception is thrown, the state of your object won't change and potentially invalidate its data. I generally find it better to delegate validation to a separate method which would be the first thing called within the setter, in order to keep the setter code relatively uncluttered.

Is a setter allowed to change the value (maybe convert a valid value
  to some canonical internal representation)?

In very rare cases, maybe.  In general, it is probably better not to. This is the sort of thing best left to another method.

Title: What should be allowed inside getters and setters?

Body:
I got into an interesting internet argument about getter and setter methods and encapsulation. Someone said that all they should do is an assignment (setters) or a variable access (getters) to keep them "pure" and ensure encapsulation.

Am I right that this would completely defeat the purpose of having getters and setters in the first place and validation and other logic (without strange side-effects of course) should be allowed?

When should validation happen?

When setting the value, inside the setter (to protect the object from ever entering an invalid state - my opinion)

Before setting the value, outside the setter

Inside the object, before each time the value is used

Is a setter allowed to change the value (maybe convert a valid value to some canonical internal representation)?

Body:
I remember having a similar argument with my lecturer when learning C++ at university. I just couldn't see the point of using getters and setters when I could make a variable public.  I understand better now with years of experience and I've learned a better reason than simply saying "to maintain encapsulation".

By defining the getters and setters, you will provide a consistent interface so that if you should wish to change your implementation, you're less likely to break dependent code. This is especially important when you classes are exposed via an API and used in other apps or by 3rd parties.  So what about the stuff that goes into the getter or setter?

Getters are generally better off implemented as a simple dumbed-down passthrough for access to a value because this makes their behaviour predictable. I say generally, because I've seen cases where getters have been used to access values manipulated by calculation or even by conditional code. Generally not so good if you are creating visual components for use at design time, but seemingly handy at run time. There's no real difference however between this and using a simple method, except that when you use a method, you are generally more likely to name a method more appropriately so that the functionality of the "getter" is more apparent when reading the code.

Compare the following:

int aValue = MyClass.Value;

and

int aValue = MyClass.CalculateValue();

The second option makes it clear that the value is being calculated, whereas the first example tells you that you are simply returning a value without knowing anything about the value itself.

You could perhaps argue that the following would be clearer:

int aValue = MyClass.CalculatedValue;

The problem however is that you are assuming that the value has already been manipulated elsewhere.  So in the case of a getter, while you may wish to assume that something else might be going on when you are returning a value, it is difficult to make such things clear in the context of a property, and property names should never contain verbs otherwise it makes it difficult to understand at a glance whether the name used should be decorated with parentheses when accessed.

Setters are a slightly different case however.  It is entirely appropriate that a setter provide some additional processing in order to validate the data being submitted to a property, throwing an exception if setting a value would violate the defined boundaries of the property. The problem that some developers have with adding processing to setters however is that there is always a temptation to have the setter do a little more, such as perform a calculation or a manipulation of the data in some manner.  This is where you can get side-effects that can in some cases be either unpredictable or undesirable.

In the case of setters I'm always apply a simple rule of thumb, which is to do as little as possible to the data.  For example, I will usually allow either boundary testing, and rounding so that I can both raise exceptions if appropriate, or avoid unnecessary exceptions where they can be sensibly avoided.  Floating point properties are a good example where you might wish to round excessive decimal places to avoid raising an exception, while still allowing in range values to be entered with a few additional decimal places.

If you apply some sort of manipulation of the setter input, you have the same problem as with the getter, that it is difficult to allow others to know what the setter is doing by simply naming it. For example:

MyClass.Value = 12345;

Does this tell you anything about what is going to happen to the value when it is given to the setter?

How about:

MyClass.RoundValueToNearestThousand(12345);

The second example tells you exactly what is going to happen to your data, while the first won't let you know if you value is going to be arbitrarily modified. When reading code, the second example will be much clearer in it's purpose and function.

Am I right that this would completely defeat the purpose of having
  getters and setters in the first place and validation and other logic
  (without strange side-effects of course) should be allowed?

Having getters and setters isn't about encapsulation for the sake of "purity", but about encapsulating in order to allow code to be easily refactored without risking a change to the class's interface which would otherwise break the class's compatibility with calling code. Validation is entirely appropriate in a setter, however there is a small risk is that a change to the validation could break compatibility with calling code if the calling code relies on the validation occurring in a particular way.  This is a generally rare and relatively low-risk situation, but it should be noted for the sake of completeness.

When should validation happen?

Validation should happen within the context of the setter prior to actually setting the value. This ensures that if an exception is thrown, the state of your object won't change and potentially invalidate its data. I generally find it better to delegate validation to a separate method which would be the first thing called within the setter, in order to keep the setter code relatively uncluttered.

Is a setter allowed to change the value (maybe convert a valid value
  to some canonical internal representation)?

In very rare cases, maybe.  In general, it is probably better not to. This is the sort of thing best left to another method.


问:
Where does the term "Front End" come from?
Where does the term "front-end" come from? Is there a particular presentation/talk/job-posting which is regarded as the first use of the term? Is someone credited with coining the term?

The Merriam-Webster entry for "front-end" claims the first known use of the term was 1973 but it doesn't seem to provide details about that first known use.

Likewise, the Wikipedia page about front and back ends is fairly low quality, and cites very few sources.

答:
In the real world of radio, the "front end" of a superheterodyne radio receiver comprises the preselector filter, the RF amp (if there is one: below 10 MHz, they generally aren't needed), the local oscillator, and the first mixer.

The preselector filter provides rough tuning at the incoming radio frequency.  Depending on the receiver design, it may be fixed-tuned, to select the band of interest, or (for e.g. a typical AM table radio) it may be tuned in synchronization with the local oscillator.

Really inexpensive table radios used pentagrid converter tubes (6BE6 or 12BE6) that combined the local oscillator and mixer functions in one device.  An analogous device today would be the Philips SA612AN mixer/oscillator (better known to a generation of hams as the NE602).

The front end is connected to the antenna and operates at the incoming signal frequency.  It produces output at the first intermediate frequency.

Analogously, the "front end" of a web service application is the piece that gets the incoming requests from the outside Internet at large.

ContentLicense: CC BY-SA 3.0


问:
What's a good length for Javadoc for a class that is say 800 lines long?
I'm doing a code-review on someone's code for class.

The class is about 800 lines long, contains a good dozen of functions but the description is like 1 line long.

I'm wondering, generally speaking, how long should the description of a class be? (in Java)?

答:
Long enough to adequately document the class.

According to Oracle, adequate class documentation includes:

Executive summary - A precise and concise description for the object.

State Information - Specify the state information associated with the object, described in a manner that decouples the states from the operations that may query or change these states.

OS/Hardware Dependencies - Specify any reliance on the underlying operating system or hardware. See  example.

Allowed Implementation Variances - Specify how any aspect of this object that may vary by implementation.

Security Constraints - If the object has any security constraints or restrictions, an overview of those constraints and restrictions must be provided in the class specification.

References to any External Specifications - These are class-level specifications written by Sun or third parties beyond those generated by Javadoc.


答: The Javadoc for each method should explain why that method is in the class; what it achieves.  The Javadoc for the class itself should explain why the class exists, including a synopsis of what it does, and a description of whatever it is that instances of that class are intended to represent.</p>

Title: What's a good length for Javadoc for a class that is say 800 lines long?

Body:
I'm doing a code-review on someone's code for class.

The class is about 800 lines long, contains a good dozen of functions but the description is like 1 line long.

I'm wondering, generally speaking, how long should the description of a class be? (in Java)?


问:
Will You Use an Online Technical Skills Test to Hire a Senior Developer?
There are online services such as IKM that offer skills tests in many areas, including programming.

Would you use these kind of tests when hiring for a senior developer position?

What about just for objectively benchmarking candidates before calling them for an interview? Would you use it as a step after short-listing candidates after interviews?

Is this approach more suitable in some situations compared to others? Have you personally used this kind of service or know someone who has?

答:
In theory, the idea of an online test to screen out completely unqualified applicants isn't too bad of one. Unfortunately, it's pretty close to worthless in reality.

First of all, none of the online testing sites I've looked at had a test that was really worthwhile. Second, it's all too easy for a completely unqualified person to get a friend (or whomever) to help in out for the duration of a test, and pass with flying colors without knowing anything about the subject matter.

Even if you could work around the second problem (e.g., have them take the test on a computer at your offices, with nobody else present, no chat programs, etc.) I doubt that there's such a thing as a useful online test anyway. Tests generally deal in facts, not ideas -- but programming is mostly about ideas and (particularly) exercising good judgement. While a programmer certainly needs to know some facts about the language(s) they use, a test of that sort of knowledge won't tell you much.

ContentLicense: CC BY-SA 2.5


问:
What are the best practices and strategies for transferring an outsourced software development project in-house?
What are the best methods of knowledge transfer?

What kinds of documentation should be expected?

What activities should take place before and after handover, both by the external party and ourselves?

答:
The answer to this depends on a lot of different things e.g.:

Does your team already have the skills to manage the development?

Do you have the resources to take this project on?

Is the project functionally complete, or work-in-progress?

Is the product based on a technology that the third party owns, or does it require specialist knowledge?

What time frame do you have to do this transition?

Is the third party make this transition easy or difficult? (they are losing business, it may be unprofessional and shortsighted, but some companies try to make it difficult)

Does the product run on a server, if so do you currently own the servers that it runs on?

Does the external company do user support?

Are there any compliance or legal issues?

(Note: this is by no means a formal list, nor is it exhaustive - just my suggestions, Ive so far managed one of these kinds of transitions, but the transition was planned before development started - which as DaveNay points out, makes the process much easier)

Resourcing Assessment

The first four questions deal with your ability to resource and continue to maintain the project. Obviously you need to have the skills and available resources to take the project on, so you will need to estimate the size of the project and to understand any skill gaps. You will need to figure out how much work will be required to maintain this project and deliver any agreed functionality. You need to include adequate time for training and upskilling. Have plenty of slack in the schedule, as nearer the end of the transition the vendor will have less motiviation to help you out.

To be able to assess the size of the job, you will need to get the guys who will be working on it looking at the code base as soon as possible. Depending on the quality of the code the amount of effort to onboard can vary dramatically. Make sure you get the input of the developers and consider it carefully. Some companies deliberatly make their code difficult to understand so that it is hard to migrate away from them.

In some projects you may find you need a specialist skill, possibly even one that only people working at the third party have. If this is the case (and depending on your relationship with the vendor) you may want to arrange a consultant from the vendor to work in house for 6 months to a year. Even if this is not the case, it is possibly a good strategy to go with, the vendor will not completely lose revenue from your company, and you will more effectively be able to train your team up.

Technology & Archictecture Assessment

Depending on the type and architecture of project, you will need to understand what tech requirements there are. Do you need to purchase your own servers? Are there any other hardware or software requirements, e.g. do you need software licenses, additional middleware installations. There is potentially a long list of items here that you need to consider. Go through the project with a fine tooth comb, find out every hardware and software dependency, and make a check list of each. Remember that you may need to consider things like:

Development software licenses

Database or OS licenses

Middleware licenses or hardware

Server Hardware

Network Infrastructure

Libraries and other tools

Accounts to external services (e.g. google maps, payment gateway etc.)

Development/Staging/UAT environments

Project Assessment

The next stage is to assess the project itself. Get a list of all the features that are supposed to have been implemented by the vendor, make sure you have a record of any bugs/issues or incomplete features. Submit this to the vendor and agree the final list of what they will do. This is more from a value for money standpoint - if you have paid for them you want to make sure they are done. If the relationship with the vendor is poor, or you dont have confidence in their abilities you may want to do the work yourself - but you should still compile the list and make sure your management is aware of the effort required to complete the required features or fix all the issues.

Managing the transition

You ideally want to work in parallel during the transition period. You want a decent amount of overlap time, but not too long so you dont lose the sense of urgency - how long that is depends on the size of the project, for something small 1 month should be enough, something large 6 months.

You should start the transition with the vendor doing most of the work, and gradually have your people take issues on. By the end all issues should be done by your team, with the vendor only providing support. Each developer on your team should have someone in the vendor's company who they can call to help them with issues. Try to make sure that the issues being worked on touch as many parts of the system as possible. Ive seen internal handovers where developers spend weeks 'looking into' a code base to understand it, but at the end of the period don't really gain anything more than a vague understanding of how the system fits together. Developers need to be writing or changing code to really understand the in's and out's of a system.

Relationship Management

You will need to manage three different kinds of relationships:

The vendor

Your users/customers

Your management

In terms of managing the vendor, you need to be very much on top of everything. Remember that unless they have a good chance of repeat business, or referrals, they have little incentive to make the process easy for you. Some companies will make the process very difficult.

Have one point of contact inside the vendor who has the authority to make decisions and who you can go to with any problems/issues - everyone should be in agreement that this person is responsible for ensuring a smooth transition. Make sure you get agreements up front from the vendor as to what they will and will not do, and make sure that what you agree is fixed fee. Do not agree to paying a particular rate for an unspecified amount of time, or the vendor will drag their heels. Make it clear that the number one priority for them is to transfer knowledge to your team. If the developers on their team are not forthcoming with help, or insist on doing things themselves instead of training your guys to do it, bring it up immediately with your contact.

Schedule an initial meeting/call with the development teams in both companies making it clear exactly what is expected by everyone. Schedule weekly calls (daily as the end of the handover nears), go through every issue, bug, feature and the status and make sure its on schedule.

The amount of communication with users/customers needed will depend on the amount of contact that the vendor has with them. If there is no direct contact, you should still let customers/users know what is happening, and warn them that it may lead to delays, or other issues during the transition. If there is direct contact you will need a seperate process to manage that, e.g. if they provide user support, you will also have to ensure you have the resources, training etc to do this.

You will also need to keep your management team aware of everything that is going on. If you dont, and issues come up leading to delays or disruption, the blame will fall on you and your team. Always manage upwards and be as transparent as possible. Send reports regularly to your managers, distribute them as far up as you can. Make sure the reports are concise and clear, with an overall status at the top and any issues highlighted in red (most senior managers will not read through a lot of detail). If there are issues with with the vendor, make sure that it comes through in the report. Do not try to cover up problems in the hopes that they will in time go away - chances are they wont and it will reflect badly on you.

Other

Make sure you are aware of any legal or compliance issues that you need to be, e.g. data protection and privacy laws, regulatory reporting, auditing, Sarbanes-Oxley etc. If the project you take over has any such requirements and you do not comply, the penalties can be severe.


问:
learning on the clock
Some might argue this question is too general, but because keeping up seems especially relevant to  programming, is anyone's experience that:

do employers expect you to stay current? what is the "industry standard" of expected time a programmer should spend keeping up-to-date?

is it generally acceptable that a programmer can spend some time during working hrs on meeting the expectation to keep skills current? If not, how do most programmers find the time?

 -

答:
I think what this question really goes to is what makes a good employer.  A good employer will encourage employees to continue developing their skills and will not only allow, but encourage employees to further their skills "On the clock"

This includes the many good things that @SnOrfus mentioned.

Not a bad question if phrased correctly to ask of a potential employer in an interview.

Good companies will even reimburse for getting a higher college degree.

Title: learning on the clock


问:
Should I use the factory design pattern for every class?
I've been writing a website in PHP. As the code becomes more complex, I keep finding problems that can be solved using the factory design pattern. For example: I've a got a class Page which has subclasses HTMLPage, XMLPage, etc. Depending on some input I need to return an object of either one of these classes. I use the factory design pattern to do this.

But as I encounter this problem in more classes, I keep having to change code which still initiates an object using its constructor. So now I'm wondering: is it a good idea to change all code so that it uses the factory design pattern? Or are there big drawbacks?

I'm currently in a position to change this, so your answers would be really helpful.

答:
Your question is not answerable.

"Factory" is simply too vague to be called a pattern.

If you read in GoF Design Pattern book, there is no such thing as "Factory" pattern.

Instead, there are several kinds of factory, which are Factory Method, and Abstract Factory.  Different kind of factory is solving different problem.  You should know what what problem you are trying to solve, before you decide you want to adopt a pattern.

So, tell us, what problem you want to solve?


问:
How to tell whether your programmers are under-performing?
I am a team lead with 5+ developers. I have a developer (let's call him A) who is a good programmer, who writes good clean, easy to understand code. However he is somewhat difficult to manage, and sometimes I wonder whether he is really under-performing or not.

Our company requires the developers to indicate the work progress in the bug tracker we use, not so much as to monitor the programmers but to keep the stakeholders apprised of the progress. The thing is, A only updates a task progress when it is done ( maybe 3 weeks after it is first worked on) and this leaves everyone wondering what is going on in the middle of the development week. He wouldn't change his habit despite repeated probing. ( It's OK, developers hate paperwork, I do, too)

Recent 2-3 months he on leave quite often due to various events-- either he is sick, or have to attend a lot of personal events etc. ( It's OK, bad things happen in a string. It's just a coincidence)

We define sprints, or roadmaps for each month. And in the beginning of the sprint, we will  discuss the amount of work each of the developers have to do in a sprint and the developers get to set the amount of time they need for each task. He usually won't be able to complete all of them. (It's OK, the developers are regularly missing deadlines not due to their fault).

I am based in Singapore. Not sure if that matters. Yeah, Asians are known to be reticent, but does that matter?

If only one or two of the above events happen, I won't feel that A is under-performing, but they all happen together. So I have the feeling that A is under-performing and maybe-- God forbid--- slacking off.

This is just a feeling based on my years of experience as programmer. But I could be wrong.

It is notoriously hard to measure the work of a programmer, given that not all two tasks are alike, and there lacks a standard objective to measure the commitment of a programmer to your company. It is downright impossible to tell whether the programmer is doing his job or slacking off. All you can do, is to trust them-- yeah, trusting and giving them autonomy is the best way for programmers to work, I know that, so don't start a lecture on why you need to trust your programmers, thank you every much-- but if they abuse your trust, can you know?

Outcome:

I've a straight talk with him regarding my perception on his performance. He was indignant when I suggested that I had the feeling that he wasn't performing at his best level. He felt that this was a completely unfair feeling. I then replied that this was my feeling and I didn't know whether my feeling was right or not. He would have none of this and ended the discussion immediately.

Before he left he said that he "would try to give more to the company" in a very cold tone. I was taken aback by his reaction. I am sure that I offended him in some ways. Not too sure whether that was the right thing to do for me to be so frank with him, though.

My question is: How can you tell whether your programmers are under-performing? Surely there are experience team leads who know better than me on this?

Extra notes:

I hate micromanaging. So all that we have for our software process is Sprint ( where tasks get prioritized and assigned, and at the end of the month, a review of the amount of work done). Developers would require to update the tasks as they go along everyday.

There is no standup meeting, or anything of the sort. Mainly because we have the freedom to work from home and everyone cherishes this freedom.

Although I am the one who sets the deadline, but the developers will provide the estimate for each tasks and I will decide-- based on the estimate-- the tasks that go into a particular sprint. If they can't finish the tasks at the end of the sprint, I will push them to the next. So theoretically one can just do only 1 or 2 tasks during the whole sprint and then push the remaining 99 tasks to the next sprint and still he will be fine as long as justifies this-- in the form of daily work progress updates

答:
First thing, why are your sprints that long? Sprints should never exceed two weeks. I think the majority of your problem lies there. I would recommend you to shorten the sprint time on a trial basis and then analyze your question again.

What about the code check in's? Does he checks in his code all the time?
I personally think that programmers are not really management guys and the more you try to manage, the more they will get frustrated. In fact, I hate to do those update tasks and probably that's why PM's and Leads are there for. But at the same time, I do provide a status during scrum meetings or whenever we meet. Now when you do assign a task, do they commit to a timeline or is it you who assigns them the timeline?

Therefore, the only way I could tell if someone is under performing is to map the committed timeline to % of work done. Now of course, if someone says that it will take him two days to write a method that adds up two numbers, you know there is a problem so the timeline should be something realistic and agreed by both the parties.

Take it this way- If you can write a piece of code in an hour, give him an hour + some buffer. If he is delivering that to you in that amount of time, I think then you guys are just doing fine. If he is not then question him and later its up to you to decide whether he is furnishing a reasonable explanation or not.

One thing that you can do is to integrate something like XPlanner with versioning tool.


问:
What is the career path for a software generalist?
A question on software specialties inspired this question.

How valuable is a software generalist compared to a specialist?

When I say generalist, I mean someone who can take a project from requirements to deployment, and is competent with all phases of the software development lifecycle. Someone who can put all the specialties together into a cohesive whole. An expert generalist knows his or her weaknesses and fills them by relying on specialists - example: Oracle specialists or UX specialists.

What do you see as the ultimate career path of the software generalist?

答:
A project manager that techies can respect, and who appreciates their art?

Of course, it could be a fine line before being a management toady knowing just enough to be dangerous about a lot of things...


答:
OED electronics

The earliest electronics definition in the Oxford English Dictionary is:

Electronics. The part of a radio or television receiver to which the aerial signal goes first; esp. the tuner, local oscillator, and mixer of a superheterodyne.

The first quotation of this is:

1938   G. E. Sterling Radio Man. (ed. 3) iv. 171   Thus improved ‘front end’ selectivity is indicated, and while this can be provided by merely adding more front-end tuned circuits, such a procedure wastes some of the wanted signal.

OED computing

The first computing sense in the OED is 1971:

4. a. An electronic device or computer system that supplies input or provides access to another device; the part of a computer system that a user deals with directly; spec. (in full front-end processor), a computer that processes or routes input for a central computer, e.g. in a multi-terminal system. Usu. attrib., as front-end machine, front-end system, etc.

1971   N. Chapin Computers xii. 313   Some subcenters are sufficiently extensive to be substantially free-standing complete computers, as suggested by the names given some types, such as peripheral or front-end processors.

The OED also has front-end charge/fees from 1962 and front-end loader/truck from 1959.

1970 antedating

Searching Google Books, I found some antedatings.

On-line data-acquisition systems in nuclear physics, 1969 (1970) by the National Research Council (U.S.). Ad Hoc Panel on On-line Computers in Nuclear Research uses the term nine times, the first two in quotes indicating the term is new or unfamiliar. Here's three examples:

...

...

1965 antedating

A possible 1965 can be found in Abstracts - Symposium on Biomathematics and Computer Science in the Life Sciences:

...

Title: Where does the term "Front End" come from?

Body:
Where does the term "front-end" come from? Is there a particular presentation/talk/job-posting which is regarded as the first use of the term? Is someone credited with coining the term?

The Merriam-Webster entry for "front-end" claims the first known use of the term was 1973 but it doesn't seem to provide details about that first known use.

Likewise, the Wikipedia page about front and back ends is fairly low quality, and cites very few sources.


答:
I don't think the programming profession is inherently different from other professions when it comes to identifying someone who is slacking off. You may have to go with your gut.

I personally think it's strange that A refuses to provide updates for weeks at a time. I am a programmer working from home, and there's an implicit contract between me and my employer that I need to provide daily updates on my progress. These are not "official" updates, it's just a short email or IM letting him know what's going on with the software I'm being paid to create.  The update takes less than a minute or two to write, and offers closure to both of us. For bug fixes I mark the ticket as resolved in our bug tracker by the end of the day. These are not difficult procedures for me, though I enjoy a relaxed work environment with very little paperwork.

Even casual updates would be appreciated coming from him, I'm sure. You sound very, very lenient in your post. If you've been suspecting that he's slacking for an extended period of time, you don't need another excuse to address it with him.

Title: How to tell whether your programmers are under-performing?

Body:
I am a team lead with 5+ developers. I have a developer (let's call him A) who is a good programmer, who writes good clean, easy to understand code. However he is somewhat difficult to manage, and sometimes I wonder whether he is really under-performing or not.

Our company requires the developers to indicate the work progress in the bug tracker we use, not so much as to monitor the programmers but to keep the stakeholders apprised of the progress. The thing is, A only updates a task progress when it is done ( maybe 3 weeks after it is first worked on) and this leaves everyone wondering what is going on in the middle of the development week. He wouldn't change his habit despite repeated probing. ( It's OK, developers hate paperwork, I do, too)

Recent 2-3 months he on leave quite often due to various events-- either he is sick, or have to attend a lot of personal events etc. ( It's OK, bad things happen in a string. It's just a coincidence)

We define sprints, or roadmaps for each month. And in the beginning of the sprint, we will  discuss the amount of work each of the developers have to do in a sprint and the developers get to set the amount of time they need for each task. He usually won't be able to complete all of them. (It's OK, the developers are regularly missing deadlines not due to their fault).

I am based in Singapore. Not sure if that matters. Yeah, Asians are known to be reticent, but does that matter?

If only one or two of the above events happen, I won't feel that A is under-performing, but they all happen together. So I have the feeling that A is under-performing and maybe-- God forbid--- slacking off.

This is just a feeling based on my years of experience as programmer. But I could be wrong.

It is notoriously hard to measure the work of a programmer, given that not all two tasks are alike, and there lacks a standard objective to measure the commitment of a programmer to your company. It is downright impossible to tell whether the programmer is doing his job or slacking off. All you can do, is to trust them-- yeah, trusting and giving them autonomy is the best way for programmers to work, I know that, so don't start a lecture on why you need to trust your programmers, thank you every much-- but if they abuse your trust, can you know?

Outcome:

I've a straight talk with him regarding my perception on his performance. He was indignant when I suggested that I had the feeling that he wasn't performing at his best level. He felt that this was a completely unfair feeling. I then replied that this was my feeling and I didn't know whether my feeling was right or not. He would have none of this and ended the discussion immediately.

Before he left he said that he "would try to give more to the company" in a very cold tone. I was taken aback by his reaction. I am sure that I offended him in some ways. Not too sure whether that was the right thing to do for me to be so frank with him, though.

My question is: How can you tell whether your programmers are under-performing? Surely there are experience team leads who know better than me on this?

Extra notes:

I hate micromanaging. So all that we have for our software process is Sprint ( where tasks get prioritized and assigned, and at the end of the month, a review of the amount of work done). Developers would require to update the tasks as they go along everyday.

There is no standup meeting, or anything of the sort. Mainly because we have the freedom to work from home and everyone cherishes this freedom.

Although I am the one who sets the deadline, but the developers will provide the estimate for each tasks and I will decide-- based on the estimate-- the tasks that go into a particular sprint. If they can't finish the tasks at the end of the sprint, I will push them to the next. So theoretically one can just do only 1 or 2 tasks during the whole sprint and then push the remaining 99 tasks to the next sprint and still he will be fine as long as justifies this-- in the form of daily work progress updates


答:
Obviously, there is a major communication issue here. He may well be doing fantastic work but if you've got the feeling that you don't know what he's up to then that by itself is an issue. And if you don't know what he's doing, then his coworkers probably don't either. This can cause issues when he does check his two week old code in. Especially if there was anyone working in a similar area.

You can always suggest that he checks in/provides updates more regularly to minimise these kinds of conflicts. This could allow you to couch your request in terms of helping the team rather than "I don't know what you're doing".

I know standups get a lot of hate but it doesn't actually have to be held in the same room. A quick call or a group Skype update once a day is very quick and keeps everyone on the same page.

I'm currently working from India with a team in Ireland and I can't imagine not being in communication with each of them on a daily basis and I either know roughly what each of they are at or I can find out very quickly.


答:
When it feels someone is "somewhat difficult to manage" like you describe, to better understand how does one perform and whether there are issues (objective or subjective) impacting productivity of dev team members, consider establishing a practice of regular 1:1's with your team members, as presented in an excellent article The Update, The Vent, and The Disaster:

...I’m not suggesting that every 1:1 is a tortuous affair to discover deeply hidden emergent disasters, but you do want to create a weekly place where dissatisfaction might quietly appear. A 1:1 is your chance to perform weekly preventive maintenance while also understanding the health of your team.

...The sound that surrounds successful regimen of 1:1s is silence. All of the listening, questioning, and discussion that happens during a 1:1 is managerial preventative maintenance. You’ll see when interest in a project begins to wane and take action before it becomes job dissatisfaction. You’ll hear about tension between two employees and moderate a discussion before it becomes a yelling match in a meeting. Your reward for a culture of healthy 1:1s is a distinct lack of drama.

A very strong point of mentioned article is that it is self-contained, in the sense that besides explaining benefits, it also provides a set of practical recommendations basically allowing one to start practicing regular 1:1's without digging into other sources (although looking for additional information won't hurt, you know).


问:
What should be allowed inside getters and setters?
I got into an interesting internet argument about getter and setter methods and encapsulation. Someone said that all they should do is an assignment (setters) or a variable access (getters) to keep them "pure" and ensure encapsulation.

Am I right that this would completely defeat the purpose of having getters and setters in the first place and validation and other logic (without strange side-effects of course) should be allowed?

When should validation happen?

When setting the value, inside the setter (to protect the object from ever entering an invalid state - my opinion)

Before setting the value, outside the setter

Inside the object, before each time the value is used

Is a setter allowed to change the value (maybe convert a valid value to some canonical internal representation)?

答:
Another acceptable thing to do is cloning.
In some cases, you need to make sure, that after someone gives your class eg. a list of something, he cannot change it inside your class (nor change the object in that list). Therefore you make deep copy of parameter in setter and return deep copy in getter.
(Using immutable types as parameters is annother option, but above is assuming it is not possible)
But don't clone in accessors if it is not needed. Its easy to think (but not appropriately) about properies/getters and setters as constant cost operations, so this is performance landmine waiting for user of api.</p>


答: The best part about setters and getters is that they make it easy to alter the rules of an API without changing the API. If you detect a bug, it's much more likely that you can fix the bug in the library and not have every consumer update its code base.</p>


答:
A common strategy for designing classes, which was introduced through the Eiffel language, is Command-Query Separation. The idea is that a method should either tell you something about the object or tell the object to do something, but not to do both.

This only relates to the public interface of the class, not the internal representation. Consider a data model object that's backed by a row in the database. You could create the object without loading the data in, then the first time you call a getter it actually does the SELECT. That's fine, you might be changing some internal details about how the object's represented but you're not changing how it appears to clients of that object. You should be able to call getters multiple times and still get the same results, even if they do different work to return those results.

Similarly a setter looks, contractually, like it just changes the state of an object. It might do that in some convoluted fashion—writing an UPDATE to a database, or passing the parameter on to some internal object. That's fine, but doing something unrelated to setting the state would be surprising.

Meyer (the creator of Eiffel) also had things to say about validation. Essentially, whenever an object is quiescent it should be in a valid state. So just after the constructor has finished, before and after (but not necessarily during) every external method call, the object's state should be consistent.

It's interesting to note that in that language, the syntax for calling a procedure and for reading an exposed attribute both look the same. In other words, a caller can't tell whether they're using some method or working directly with an instance variable. It's only in languages that don't hide this implementation detail where the question even arises—if callers couldn't tell, you could switch between a public ivar and accessors without leaking that change into client code.


问:
Why do so few large websites run a Microsoft stack?
Off the top of my head, I can think of a handful of large sites which utilize the Microsoft stack

Microsoft.com

Dell

MySpace

PlentyOfFish

StackOverflow

Hotmail, Bing, WindowsLive

However, based on observation, nearly all of the top 500 sites seem to be running other platforms.What are the main reasons there's so little market penetration?

Cost?

Technology Limitations?

Does Microsoft cater to corporate / intranet environments more then public websites?

I'm not looking for market share, but rather large scale adoption of the MS stack.

答:
I'll posit that it's because most of the "big websites" started out small.  Google, Youtube, Facebook et al. were all at one time single-server sites that someone built as a hobby.  They used LAMP-like stacks because: 1) they're cheap and the devs were poor and often 2) because they were at a university and university environments tend to favor OSS.

After the sites started growing, the developers just stuck to what they knew.  In the early years, there wouldn't be enough time or money to do a big system rewrite.  When, and if, that ever became an option, why switch to an entirely different base?

So I'm saying it's because that's just what they knew and had when they started.  SO isn't any different if I recall that story correctly.  The SO Founders knew MS stack, and had access to the tools/licenses/etc to start using it, and so that's what they used!

(I've also heard that they also wanted to prove that MS stack was just as good as LAMP for big sites, but that may be apocryphal.)


答:
I tend to believe that setters and getters are evil and should only be used in classes that are managed by a framework/container. A proper class design should not yield getters and setters.

Edit: a well-written article on this subject.

Edit2: public fields are a nonsense in an OOP approach; by saying that getters and setters are evil I do not mean that they should be replaced by public fields.


答:
Developers might hate the effort of documenting what they do and updating statuses - but that's part of being a professional developer. I would suggest that you could try to point out to him that his late updates of your issues log is causing an unnecessary negative perception of his work. If he doesn't see that his failure to communicate is a performance problem - well, you're his team leader; tell him that it is.

Regarding estimation - that's a classic problem. I recommend reading "Software Estimation - Demystifying the black art" by Steve McConnell. In this instance, you give the impression that most of your developers under-estimate. This is, curiously, normal, and rarely addressed. I would suggest that you've got a problem with the estimation process itself, rather than this one individual.

Try to 'close the loop' of estimate-measure-review and improve. Then, if your developers are coming in on time more regularly and this one individual isn't, you can consider what to do about him.

Finally, have the stand up meeting. Even if it's by Instant Message. All you want is everyone to know "what I did, what I'm doing today, any issues". And if there are issues, take them offline for discussion later. That's what I've done before, and it was successful for that team.


答:
Meyer's Uniform Access Principle: "All services offered by a module should be available through a uniform notation, which does not betray whether they are implemented through storage or through computation." is the main reason behind the getters/setters, aka Properties.

If you decide to cache or lazily compute one field of a class then you can change this anytime if you have only exposed property accessors and not the concrete data.

Value objects, simple structures don't need this abstraction but a fully fledged class does, in my opinion.


问:
should I extend or create instance of the class
I have two classes  Class A and Class B

In Class A, I have three methods that perform the save, delete and select operation based upon the object I pass them. In Class B I perform the logic operations, such as modification to the property of the object before being passed to the methods of Class A.

My problem is in Class B, should it extend Class A, and call the methods of class A , by parent::methodName or create instance of class A and then call

Class A does not includes any property just methods.

```<code>class A{
  public function save($obj){
         //code here
    }

   public function delete($obj){
         //code here
    }

    public function select($obj){
         //code here
    }
 }
</code>```

//Should I extend class A, and call the method by parent::methodName($obj)
   or create an instance of class A, call the method $instanceOfA->methodName($obj);

```<code> class B extends A{

    public function checkIfHasSaved($obj){
         if($obj->saved == 'Yes'){
                  parent::save($obj);   //**should I call the method like this**
                 $instanceOFA = new A();   //**or create instance of class A and call without extending class A**
                 instanceOFA->save($obj);
            }
             //other logic operations here
      }

 }
</code>```

答:
Since it's semantically correct to ask your object if it's saved then I guess it would be OK to ask it to save. If you extend saving will be a public method on your object and available from the outside.

You'll need to decide if that's OK or not.


问:
Naming convention: field starting with "m" or "s"
I saw lot of code (for example some Android source code) where fields name start with a m while static fields start with s

Example (taken from Android View class source):

private SparseArray<Object> mKeyedTags;
private static int sNextAccessibilityViewId;
```

I was wondering what m and s stand for... maybe is m mutable and s static?

答:
m is typically for a public member (see this answer for common C code conventions Why use prefixes on member variables in C++ classes).

I've never seen s before, but based on that answer:

m for members

c for constants/readonlys

p for pointer (and pp for pointer to pointer)

v for volatile

s for static

i for indexes and iterators

e for events

Have you read any published standards for the project you've seen that code in?

One of the most famous prefix notation systems is Hungarian Notation.

There is a excellent blog post by Joel Spolsky on prefixes: Making Wrong Code Look Wrong


答:
It's called hungarian notation, and it sucks. Do some research on it, it's actually a misunderstood concept.

It originated with a good intent, indicate variables that may cause harm, such as input directly from the user in a HTML form (be sure to strip out HTML before storing to DB for instance).

```<code>var unsafeComment = $('.input').val();
save(unsafeComment);//looks wrong
//strip out html then save
</code>```

The m is for member and s for static.

Title: Naming convention: field starting with "m" or "s"

Body:
I saw lot of code (for example some Android source code) where fields name start with a m while static fields start with s

Example (taken from Android View class source):

private SparseArray<Object> mKeyedTags;
private static int sNextAccessibilityViewId;
```

I was wondering what m and s stand for... maybe is m mutable and s static?

Body:
It's called hungarian notation, and it sucks. Do some research on it, it's actually a misunderstood concept.

It originated with a good intent, indicate variables that may cause harm, such as input directly from the user in a HTML form (be sure to strip out HTML before storing to DB for instance).

var unsafeComment = $('.input').val();
save(unsafeComment);//looks wrong
//strip out html then save

The m is for member and s for static.


问:
Cocoa Applications: Use custom preference dialog or system preference app?
When writing Cocoa Applications for MacOSX, you have the choice of either having a custom preference dialog, or using the Settings.app to manage your preferences.

Functionality wise, there is no difference at all between the two (apart from the fact that preferences in the Settigns.app can be accessed when your app is not running).

Which solution do you use and why?

答:
Settings.app? That's an iOS thing. On the Mac it's called System Preferences.app.

On the Mac, you should write your own preferences dialog (or use one of the third party frameworks that do them for you).

The exception is if your app does something when it isn't running (e.g. you're a front-end for a database server, which runs in the background), or if you don't have a UI that includes a menubar (e.g. you're a system utility that augments other apps).

This is different to iOS, where app settings can go in Settings.app.


答:
This should be a surprisingly easy problem to solve.

Have a second meeting with him. Tell him that you accept that it's probably your perception of reality that is at fault. Then qualify that with "however, if that is the case then we need to work together to improve my perception." Finally challenge him to solve that problem, so he doesn't feel micro-managed.

This exact thing happened to me a long time ago. For me, the issue was that I dislike the possibility that anyone might think I'm seeking extra credit for simply doing my job. And that was fair enough, but there has to be a regular feedback loop between any member of staff and their line-manager.

If there isn't then you get these problems.

Regular, planned, 1:1s are a great idea. And, as people have pointed out, standups do not need to be orthogonal to working from home. But they must involve the three questions: What did you do yesterday? What are you planning to do today? And the one most people forget ... What (if anything) is holding you up?

That said, you should try to discourage situations where team members never work together. I've worked in that situation before and it seeded distrust within the team and outside it. Have a regular day that you all come into the office. Have a regular meeting where people can voice some ideas on improving processes or whatever.

Don't make it a line-reporting event. Make it an opportunity to just talk. You'll be surprised what you learn. If possible, turn that into a social event, go for a couple of drinks on work time as a bonding exercise.


答:
The examples given by you could have had meaningful class names, this would favor much better responses.

Since class A does not have any properties, it is safe to use methods from the instance you already have:

```<code>class B extends A
{
    public function checkIfHasSaved($obj)
    {
        if($obj->saved)
            $this->save($obj);
    }
}
</code>```

Another alternative would be to use Dependency injection instead:

```<code>class B
{
    protected $a;

    public function __construct(A $theObject)
    {
        $this->a = $theObject;
    }

    public function checkIfHasSaved($obj)
    {
        if($obj->saved)
            $this->a->save($obj);
    }
}
</code>```

Title: should I extend or create instance of the class

Body:
I have two classes  Class A and Class B

In Class A, I have three methods that perform the save, delete and select operation based upon the object I pass them. In Class B I perform the logic operations, such as modification to the property of the object before being passed to the methods of Class A.

My problem is in Class B, should it extend Class A, and call the methods of class A , by parent::methodName or create instance of class A and then call

Class A does not includes any property just methods.

```<code>class A{
  public function save($obj){
         //code here
    }

   public function delete($obj){
         //code here
    }

    public function select($obj){
         //code here
    }
 }
</code>```

//Should I extend class A, and call the method by parent::methodName($obj)
   or create an instance of class A, call the method $instanceOfA->methodName($obj);

```<code> class B extends A{

    public function checkIfHasSaved($obj){
         if($obj->saved == 'Yes'){
                  parent::save($obj);   //**should I call the method like this**
                 $instanceOFA = new A();   //**or create instance of class A and call without extending class A**
                 instanceOFA->save($obj);
            }
             //other logic operations here
      }

 }
</code>```

Body:
The examples given by you could have had meaningful class names, this would favor much better responses.

Since class A does not have any properties, it is safe to use methods from the instance you already have:

class B extends A
{
    public function checkIfHasSaved($obj)
    {
        if($obj->saved)
            $this->save($obj);
    }
}

Another alternative would be to use Dependency injection instead:

class B
{
    protected $a;

    public function __construct(A $theObject)
    {
        $this->a = $theObject;
    }

    public function checkIfHasSaved($obj)
    {
        if($obj->saved)
            $this->a->save($obj);
    }
}


问:
What reasons are there to reduce the max-age of a logo to just 8 days?
Most websites set max-age=31536000 (1 year) on the Cache-control headers of static assets such as logo images. Examples:

YouTube

Yahoo

Twitter

BBC

But there is a notable exception: Google's logo has max-age=691200 (8 days).

I've checked the headers on the Google logo in the past, and it definitely used to be 1 year. (Also, it used to be part of a sprite, and now it is a standalone logo image, but that's probably another question...)

What could be valid technical reasons why they would want to reduce its cache lifetime to just 8 days? Google's homepage is one of the most carefully optimised pages in the world, so I imagine there's a good reason.

Edit:

Please make sure you understand these points before answering:

Nobody uses short max-age lifetimes to allow modifying a static asset in future. When you modify it, you just serve it at a different URL. So no, it's nothing to do with Google doodles. Think about it: even if Google didn't understand this basic trick of HTTP, 8 days still wouldn't be appropriate, as only those users who don't have the original logo cached would see the doodle on doodle-day – and then that group of users would go on seeing the doodle for the following 8 days after Google changed it back :)

Web servers do not worry about "'filling up' the caches of clients (or proxies). The client manages this by itself – when it hits its own storage limit, it just starts dropping the lowest priority items to make space for new items. The priority score is based on the question "How likely am I to benefit from having cached this URL?", which is nothing to do with what max-age value the server sent when the URL was originally requested; it's a heuristic based on the 'frecency' of requests for that URL. The max-age simply lets the server set a cut-off point – the time at which the client is supposed to discard the item regardless of how often it's being re-used. It would be very nice and trusting of a downstream client/proxy to rely on origin servers 'holding back' from filling up their caches, but I don't think we live in that world ;)

答: Probably because they change the logo often, when they celebrate a personality or an event.</p>


答: Probably because they change their logo often: caching servers would be full with Google logos that aren't used. This setting make caches remove the logo from their storage sooner.</p>

Title: What reasons are there to reduce the max-age of a logo to just 8 days?

Body:
Most websites set max-age=31536000 (1 year) on the Cache-control headers of static assets such as logo images. Examples:

YouTube

Yahoo

Twitter

BBC

But there is a notable exception: Google's logo has max-age=691200 (8 days).

I've checked the headers on the Google logo in the past, and it definitely used to be 1 year. (Also, it used to be part of a sprite, and now it is a standalone logo image, but that's probably another question...)

What could be valid technical reasons why they would want to reduce its cache lifetime to just 8 days? Google's homepage is one of the most carefully optimised pages in the world, so I imagine there's a good reason.

Edit:

Please make sure you understand these points before answering:

Nobody uses short max-age lifetimes to allow modifying a static asset in future. When you modify it, you just serve it at a different URL. So no, it's nothing to do with Google doodles. Think about it: even if Google didn't understand this basic trick of HTTP, 8 days still wouldn't be appropriate, as only those users who don't have the original logo cached would see the doodle on doodle-day – and then that group of users would go on seeing the doodle for the following 8 days after Google changed it back :)

Web servers do not worry about "'filling up' the caches of clients (or proxies). The client manages this by itself – when it hits its own storage limit, it just starts dropping the lowest priority items to make space for new items. The priority score is based on the question "How likely am I to benefit from having cached this URL?", which is nothing to do with what max-age value the server sent when the URL was originally requested; it's a heuristic based on the 'frecency' of requests for that URL. The max-age simply lets the server set a cut-off point – the time at which the client is supposed to discard the item regardless of how often it's being re-used. It would be very nice and trusting of a downstream client/proxy to rely on origin servers 'holding back' from filling up their caches, but I don't think we live in that world ;)


问:
Is there an appropriate coding style for implementing an algorithm during an interview?
I failed an interview question in C years ago about converting hex to decimal by not exploiting the ASCII table if (inputDigitByte > 9) hex = inputDigitByte - 'a'.  The rise of Unicode has made this question pretty silly, but the point was that the interviewer valued raw execution speed above readability and error handling.

They tell you to review algorithms textbooks to prepare for these interviews, yet these same textbooks tend to favor the implementation with the fewest lines of code, even if it has to rely on magic numbers (like "infinity") and a slower, more memory-intensive implementation (like a linked list instead of an array) to do that.  I don't know what is right.

Coding an algorithm within the space of an interview has at least 3 constraints: time to code, elegance/readability, and efficiency of execution.  What trade-offs are appropriate for interview code?

How much do you follow the textbook definition of an algorithm?  Is it better to eliminate recursion, unroll loops, and use arrays for efficiency?  Or is it better to use recursion and special values like "infinity" or Integer.MAX_VALUE to reduce the number of lines of code needed to write the algorithm?

Interface: Make a very self-contained, bullet-proof interface, or sloppy and fast?  On the one extreme, the array to be sorted might be a public static variable.  On the other extreme, it might need to be passed to each method, allowing methods to be called individually from different threads for different purposes.

Is it appropriate to use a linked-list data structure for items that are traversed in one direction vs. using arrays and doubling the size when the array is full?  Implementing a singly-linked list during the interview is often much faster to code and easier remember for recursive algorithms like MergeSort.

Thread safety - just document that it's unsafe, or say so verbally?  How much should the interviewee be looking for opportunities for parallel processing?

Is bit shifting appropriate? x / 2 or x >> 1

Polymorphism, type safety, and generics?

Comments?

Variable and method names: qs(a, p, q, r) vs: quickSort(theArray, minIdx, partIdx, maxIdx)

How much should you use existing APIs?  Obviously you can't use a java.util.HashMap to implement a hash-table, but what about using a java.util.List to accumulate your sorted results?

Are there any guiding principals that would answer these and other questions, or is the guiding principal to ask the interviewer?  Or maybe this should be the basis of a discussion while writing the code?

If an interviewer can't or won't answer one of these questions, are there any tips for coaxing the information out of them?

答:
In a typical setting of whiteboard interview, lasting about 30-60 minutes, you won't have neither time nor space for elaborate, "real-world" implementation. So you need to make various trade-offs of different kinds.

In every case, though, the most important thing is always to communicate them properly to the interviewer. Examples include:

"I assume input data is correct. Normally I would add a check for $propertyX and $propertyY, but I'm omitting it here for brevity". (error checking and handling)

"This part is growing a bit complex, so normally I would extract it into separate function taking $arguments and returning $result." (refactoring)

"For now, I will use this $dataStructure and $helperAlgorithm but I think it's possible to use $moreEfficientApproach instead." (optimization; note that typically you'll be asked for implementing that better approach anyway, but doing the simple one first is often very helpful)

"I will use $functionThatDoesntExistYet in order to do that, which I will implement once I finish with the main algorithm." (abstraction)

"$madeUpNotation means $someSemanticConcept here, I'll use that for brevity." (language boilerplate, e.g. importing set/dict/lambda syntax from Python to Java)

I, for one, think that making such trade-offs consciously can actually score you more points than making everything "properly", especially if the latter involves writing big parts of code not directly relevant to the problem. The burden is on you, however, to demonstrate that you know what you are doing and are aware of the shortcuts you're taking - lest the interviewer might think you are forgetting the important details.


答:
US patent 2598857, filed on January 29, 1949

This patent specifically talks about a "front end" receiver in the sense of a block diagram.

Moreover, it is apparent that a considerable saving in cost of a wide range television receiver "front end" make be realized through the use of the present invention. For example, in a television receiver RF "front end" incorporating a push-pull RF amplifier, ...

This usage is already older than am I. I think it's considerably older than that.

US patent 1795397, filed on Dec 29, 1927.

This patent uses the terms "front end" and "back end" extensively. A couple of example uses:

Fig. 5 corresponds with Fig. 4 but has the receiver at the "front end" instead of at the "back end".

It is known that a single wave-antenna can be "compensated" to secure null reception from any specufued angle of incidence of the radio waves, by suitably combining a small portion of the front-end current with the back-end output current. (See, for instance, Fig. 19 of the above-cited paper by Beverage et al.)

The referenced article is by Harold H. Beverage, published in the March, 1923 issue of the "Journal of the A.I.E.E." (Good luck finding that on the internet.) I looked at patents by Beverage, and he doesn't appear to use the term "front end" or "back end" in his patents.


答:
There's lots of great advice here, and I don't want to take away from any of it, so I'm posting this as a separate answer.

First, it is evident to me (and apparently others) that you have not discovered the root of the problem.  You're staring at a symptom and trying to cure that.  You need to find out what is causing so much friction between yourself and this developer.  Perhaps you're being too authoritative (my Product Owner recently described herself as having "Infinite Power" over a project and that was offensive to me, even though she laughed when she said it).  Perhaps he is having severe family problems (would explain all the time out of work).  There is a root problem here, and until you find it, this will not be fixed.

Good Catch!

If his performance could be better, that's great that you've determined that.  Remember though, that if his bad performance is still good performance by comparison, then you need to tread carefully to avoid losing a good developer.  Good developers are hard to come by, and good developers require a very specific set of things.  Perhaps take a look at the Joel Test to see if his needs are being met.

Find the Source of the Problem

If he is unhappy with something related to the job he's doing, then you can only fix it by determining the source of the problem.  Let me be clear, you said your programmer wrote good code.  That means that he loves programming.  It is more than evident that he is frustrated at work (from your description of the meeting), and you're probably right that his performance is below where it should be, but don't assume.  Remember that many programmers just don't have social skills.

You're Not Perfect Either

Remember that sometimes you're going to have personality conflicts, especially with introverts.  If this turns out to be a personality conflict, consider how far you're willing to go to gain an increase in performance (see 1)

All of That Said

I wrote a blog post about Managing Programmers.  I think you should read it.

http://deltreey.blogspot.com/2012/07/managing-programmers.html

I cannot emphasize enough the last part of that post.

If your developers are any good at all, they want to code.

Your programmer, even if he is slacking off, does not want to be slacking off.  You have to find the root of this problem, and it may turn out to be something that simply cannot be fixed and he has to be let go, but whatever it is, you cannot make an informed decision without determining it.


答:
Consultant

I did this for a while, and being a generalist is the #1 skill that will make you a success.  When people have a problem, they typically have been solving that problem one way for a long time, and need consultants to get a fresh perspective.  As a consultant you need to know about ALL KINDS of products, open source, closed source, Oracle, Microsoft, Red Hat.  You need to know what's good, what's bad, and what's best for the client.  To be able to do that you need to be a generalist and know how to be an expert FAST.  To be an expert fast (without already being one), you need to know the core principles and practices of software development, without only knowing ONE implementation of them.  You need to be able to pick up things without having seen them before and within a short time be able to be proficient in it.  As a self-proclaimed generalist myself, consulting was the best career move, and the most fun I've had doing software development.  New experiences, new and diverse range of projects and technologies, good pay, and generalist traits help you succeed.

Title: What is the career path for a software generalist?

Body:
A question on software specialties inspired this question.

How valuable is a software generalist compared to a specialist?

When I say generalist, I mean someone who can take a project from requirements to deployment, and is competent with all phases of the software development lifecycle. Someone who can put all the specialties together into a cohesive whole. An expert generalist knows his or her weaknesses and fills them by relying on specialists - example: Oracle specialists or UX specialists.

What do you see as the ultimate career path of the software generalist?


问:
Supporting and testing multiple versions of a software library in a Maven project
My company has several versions of its core software in use by our customers at any one time. My job is to write bespoke Java software for the customers based on the version of core software they happen to be running.

I've created a common Java library that performs many of the tasks I regularly require in a normal project. This is a Maven project that I deploy to our local Artifactory and pull down into other Maven projects when required.

Currently this library includes v1.3 of our core software, for example:

<dependency>
  <groupId>com.foo</groupId>
  <artifactId>core-software</artifactId>
  <version>1.3</version>
</dependency>
```

<p>As a result, that's the only version I'm completely confident is compatible due to the success of the unit tests. <strong>How can I best automate testing with other versions of the core software to ensure compatibility?</strong></p>

<hr>

<p>One possibility is to create a series of Maven projects that incorporate my library and override the core-software version:</p>

<pre class="lang-xml prettyprint-override"><code><!-- Override core version -->
<dependency>
  <groupId>com.foo</groupId>
  <artifactId>core-software</artifactId>
  <version>1.2</version>
</dependency>
<!-- Incorporate shared library: -->
<dependency>
  <groupId>com.foo</groupId>
  <artifactId>common-lib</artifactId>
  <version>1.0</version>
</dependency>
</code>```

I could then execute the unit tests from my main project to ensure they all pass (I need to figure that bit out). The benefit of this approach is that I can incorporate these additional Maven projects in my continuous integration server and be alerted whenever a check-in breaks compatibility with another core software version.

Can anyone suggest a better alternative?

答:
If it applies, you can create a branch in source control for each version and instruct your CI tool to build/test all active branch heads.

This may be problematic if you have an active branch that you do not want to build/test. You'd have to work it out based on your needs, but I would suggest you consider leveraging version control if possible.


问:
Anybody use the Team Software Process (TSP) and/or Personal Software Process (PSP)?
More info on it here:
http://en.wikipedia.org/wiki/Team_Software_Process

What has your experience been?

答:
What none of you developers realise is that through TSP and PSP you as a developer can write your own resume with evidence (data) to back it up. Also your data is your personal data and as a TSP Coach we may not discuss your data with anyone except the owner of that data... Yes, there is a process that needs to be adhered to and certainly each developer needs to be disciplined to capture the data.

TSP has assisted our organization in getting our estimations more accurate but in order to do that you need to be disciplined as developers to capture accurate data; garbage in garbage out. TSP/PSP doesn't bring anything new to the table, only the fact that there is a process which most of us learned during our courses.

Since the advent of 4GL Languages these disciplines all flew out the window and the compiler became the way of testing your code. TSP brings back the old ways of doing things by producing a design (program specification) and then a personal review as well as a peer review. Then you code it and once done you review your code and then get your peers to review; all this is timed and defects logged.

So for people who like to work in chaos this is not the way to go.

You have to be be willing to change and learn as you will see from your own data where you can improve.


问:
Record management system java web framework
We're currently reconsidering technologies and frameworks to get more agile with "simple" RMS CRUD-based projects. In short, short-living things like this

Right now we have a custom extension on top of SmartGWT but after some time it has proven not to be flexible enough.

I also personally dislike the java-js compilation process and the whole GWT codebase. Not only is the design ugly, it also makes certain low-level js things very complicated if not completely impossible. So what I'm looking for is:

closest to web as possible, like JSF or possibly Tapestry, it is very important to be able get "low" and weave framework if necessary. Happens more often than we thought.

datagrid capable - Ext.js & PrimeFaces looks pretty good, Vaadin does too.

db-schema generators (optional, no matter in which way)

If it were only on me, I'd probably stick to Ext.js + custom rest-based java solution, possibly generated from database schema (not sure about concrete tooling yet).

I only have experience with vanilla Ext.js, vanilla GWT and JSF 2.0 / Seam, so it hard for me to judge or even propose other frameworks.

Whats your experience?

What are the downsides you've faced?

答:
If you're comfortable with Java, you might give Grails a shot. It provides a lot of what you're looking for:

Easy web layer tailoring with Groovy Server Pages. Integrating Ext, jQuery, Angular is as simple as with a standard HTML page.

Object oriented database management. You define Domain Objects, and the framework builds your database schema for you. You can tweak it to the point where you're controlling every aspect the DB too. It's not quite as good as Rails' Migrations IMHO, but it can remove a layer from active management by developers.

Excellent REST support with XML and JSON output. Grails makes it very easy to expose your domain objects as RESTful services.

Groovy!!! So so so much better than Java, again, IMHO.

At my company, we've used Grails extensively with Ext. It integrates very well with Ext's DataStore component thanks to the simple REST support mentioned above. The two frameworks are completely decoupled; there's nothing in Grails that forces you to use Ext in any particular way or hides particular Ext options from you.

Every tool is going to have limitations, so it may not be exactly what you're looking for. Personally, I have found it to be a very productive framework.


问:
PHP file_put_contents File Locking
The Senario:

You have a file with a string (average sentence worth) on each line. For arguments sake lets say this file is 1Mb in size (thousands of lines).

You have a script that reads the file, changes some of the strings within the document (not just appending but also removing and modifying some lines) and then overwrites all the data with the new data.

The Questions:

Does 'the server' PHP, OS or httpd etc. already have systems in place to stop issues like this (reading/writing half way through a write)?

If it does, please explain how it works and give examples or links to relevant documentation.

If not, are there things I can enable or set-up, such as locking a file until a write is completed and making all other reads and/or writes fail until the previous script has finished writing?

My Assumptions and Other Information:

The server in question is running PHP and Apache or Lighttpd.

If the script is called by one user and is halfway through writing to the file and another user reads the file at that exact moment. The user who reads it will not get the full document, as it hasn't been written yet. (If this assumption is wrong please correct me)

I'm only concerned with PHP writing and reading to a text file, and in particular, the functions "fopen"/"fwrite" and mainly "file_put_contents". I have looked at the "file_put_contents" documentation but have not found the level of detail or a good explanation of what the "LOCK_EX" flag is or does.

The scenario is an example of a worst case scenario where I would assume these issues are more likely to occur, due to the large size of the file and the way the data is edited. I want to learn more about these issues and don't want or need answers or comments such as "use mysql" or "why are you doing that" because I'm not doing that, I just want to learn about file read/writing with PHP and don't seem to be looking in the right places/documentation and yes I understand PHP is not the perfect language for working with files in this way.

答:
In PHP documentation for file_put_contents() you can find in example#2 the usage for LOCK_EX, puting simply:

```<code>file_put_contents('somefile.txt', 'some text', LOCK_EX);
</code>```

The LOCK_EX is a constant with an integer value than can be used on some functions in a bitwise.

There are also a specific function in order to control locking for files: flock() manner.

Title: PHP file_put_contents File Locking

Body:
In PHP documentation for file_put_contents() you can find in example#2 the usage for LOCK_EX, puting simply:

file_put_contents('somefile.txt', 'some text', LOCK_EX);

The LOCK_EX is a constant with an integer value than can be used on some functions in a bitwise.

There are also a specific function in order to control locking for files: flock() manner.


问:
Ternary operator considered harmful?
For example, would you prefer this one-liner

```<code>int median(int a, int b, int c) {
    return (a<b) ? (b<c) ? b : (a<c) ? c : a : (a<c) ? a : (b<c) ? c : b;
}
</code>```

or an if/else solution involving multiple return statements?

When is ?: appropriate, and when is it not? Should it be taught to or hidden from beginners?

答:
Biggest win: Showing that there is a single target of action.

```<code>if ( $is_whatever )
    $foo = 'A';
else
    $foo = 'B';
</code>```

There are two code paths that you can follow, and the reader must read carefully to see which two variables are being set.  In this case, it's only one variable, but the reader has more to read to figure that out.  After all, it could have been this:

```<code>if ( $is_whatever )
    $foo = 'A';
else
    $bar = 'B';
</code>```

With the ternary operator, it's clear that only one variable is being set.

```<code>$foo = $is_whatever ? 'A' : 'B';
</code>```

At the very lowest level, it is the DRY (Don't Repeat Yourself) principle at its most basic.  If you can specify $foo only once, do so.

Title: Ternary operator considered harmful?

Body:
Biggest win: Showing that there is a single target of action.

if ( $is_whatever )
    $foo = 'A';
else
    $foo = 'B';

There are two code paths that you can follow, and the reader must read carefully to see which two variables are being set.  In this case, it's only one variable, but the reader has more to read to figure that out.  After all, it could have been this:

if ( $is_whatever )
    $foo = 'A';
else
    $bar = 'B';

With the ternary operator, it's clear that only one variable is being set.

$foo = $is_whatever ? 'A' : 'B';

At the very lowest level, it is the DRY (Don't Repeat Yourself) principle at its most basic.  If you can specify $foo only once, do so.


问:
Why are tools like git-svn that allow git to integrate with svn useful?
I have read these related questions:

I'm a Subversion geek, why should I consider or not consider Mercurial or Git or any other DVCS?

git for personal (one-man) projects. Overkill?

...and I understand why git is useful. What I don't understand is why tools like git-svn that allow git to integrate with svn are useful.

When, for example, a team is working with svn, or any other centralised SCM, why would a member of the team opt to use git-svn? Are there any practical advantages for a developer that has to synchronize with a centralized repository?

答:
I use git-svn because I use my own local (and PRIVATE) branches for organizing my workflow and for experimenting.  With centralized I can't create a branch unless it is on the server where everyone else has access.  I suppose one could set up special permissions/groups on the server such that when a branch is created only I have access but TBH that seems like more work than necessary.

And we are moving to git as our central SCM, it's just a few months away but it allows developers to learn git without having to change the entire infrastructure.


答:
Forcing a company to move from one VCS to another is a big decision to make. Git is a big learning curve for people who have only used SVN, no matter what people tell you. If you have a team of 30 of those people, it doesn't matter how good an idea a switch to Git is, it's a big decision.

But, if you prefer a DVCS (I do, just for the ability to do fast, regular commits, without pushing them to the build server), there should be nothing stopping you, personally, from using it, without causing major disruption to everyone else. After all, DVCS is just the ability to clone a central database and then clone it again and again.

And that's what Git-Svn (or even Git-tf) does for you. No one else even needs to know that you're using it.

Slowly, you can convert people over to the dark side and, if there is ever enough of a pro-Git movement to make it worth everyone's while, you can shift the central repository over to Git.

Title: Why are tools like git-svn that allow git to integrate with svn useful?

Body:
I have read these related questions:

I'm a Subversion geek, why should I consider or not consider Mercurial or Git or any other DVCS?

git for personal (one-man) projects. Overkill?

...and I understand why git is useful. What I don't understand is why tools like git-svn that allow git to integrate with svn are useful.

When, for example, a team is working with svn, or any other centralised SCM, why would a member of the team opt to use git-svn? Are there any practical advantages for a developer that has to synchronize with a centralized repository?


问:
systems/software engineering design process
I just developed my first non-trivial android app. It was a complete nightmare. I came up with an idea, build the app, changed my idea, and implemented a lot of input from others on new features. All in all my app took 10 times longer than I think that it should have, it is almost impossible to look the source code and tell what's going on with the classes, and may or may not have unused methods that I'll never be able to find...

So I would like an opinion from those of you with experience on how to plan out my designs for the future. I created a flow chart (pencil drawn) of a plan:

I would like constructive criticism.

答: The biggest step you're missing is a refactor step.  As soon as you don't use a method anymore, delete it.  As soon as you can't follow the flow of a class, refactor it.  The first time you have to figure out again why you did something a certain way, document it.  Always be on the lookout for opportunities to improve the code, and take them before it gets out of hand.  It will save you time in the long run.</p>


答:
I really like Vaadin for UI prototyping.  The code you write is similar to Swing/AWT.  You can bang out very rich UIs in very little time with very little code, without having to worry about shuttling data.

In normal usage, it takes care of all the HTML+css+js for you.  However, you can use low-level components and settings for times where you want more control.  You likely won't need to very often; you'll be surprised how functional the API is.  Check out the demos and the 3rd-party directory.

It's not a good fit for web sites, but is great for web applications.

Title: Record management system java web framework

Body:
We're currently reconsidering technologies and frameworks to get more agile with "simple" RMS CRUD-based projects. In short, short-living things like this

Right now we have a custom extension on top of SmartGWT but after some time it has proven not to be flexible enough.

I also personally dislike the java-js compilation process and the whole GWT codebase. Not only is the design ugly, it also makes certain low-level js things very complicated if not completely impossible. So what I'm looking for is:

closest to web as possible, like JSF or possibly Tapestry, it is very important to be able get "low" and weave framework if necessary. Happens more often than we thought.

datagrid capable - Ext.js & PrimeFaces looks pretty good, Vaadin does too.

db-schema generators (optional, no matter in which way)

If it were only on me, I'd probably stick to Ext.js + custom rest-based java solution, possibly generated from database schema (not sure about concrete tooling yet).

I only have experience with vanilla Ext.js, vanilla GWT and JSF 2.0 / Seam, so it hard for me to judge or even propose other frameworks.

Whats your experience?

What are the downsides you've faced?


问:
How are blocking calls implemented?
This may be a very simple question. I'm curious how blocking calls are implemented. Specifically, how do they block? Is this just thread.sleep?</p>

答:
Methods don't return control to the caller until their work is completed, that's all.  In your socket class example, the method doesn't return the data until it actually receives it.

In most cases, where you're seeing something like Thread.Sleep(1000) in a code example, you are not seeing blocking per se, but merely simulating work.

Where Thread.Sleep is being used legitimately, it is relinquishing control to other threads, with an implicit statement: "I can wait awhile before you return control to me."  Thread.Sleep is not required; the operating system will normally preempt the thread for short periods of time anyway, if work on other threads also needs to be completed.

Title: How are blocking calls implemented?


答:
Using Git combined with SVN can be useful if your develop under strict check-in rules. For example checking into the central repository may require peer reviews, unit test cases, design docs, and several paper forms.

Although these rules are good, they makes check-ins to the central server a burden. I've found developers tend to wait and do a giant check-in to consolidate the paper work.

With GIT you can check-in locally so you have many little save points as you develop. It's just your local disk so you don't need to do any peer-review, paper work, or unit test documents.

You gain a much richer set of save points as you develop. And save points are the entire point of using source control (over old fashioned backups).


答:
In most system calls on most OS's, your blocking call ultimately causes some request to go out to be executed by the kernel while the calling thread is suspended by the scheduler/dispatcher until that work is complete. Typically this work is some kind of IO request to peripheral hardware (ie network card/hard disk/etc). The peripheral hardware can use a processor interrupt to signal the CPU/kernel that some piece of work is complete (or some other piece of info about the work). Once the work is complete, the kernel wakes up the calling thread and allows execution to continue from where it was waiting. The hardware/kernel together have prepared any outputs (buffers/errors etc) for the user-facing calling function and these outputs are handed back to the caller.

The specific details of how this happens are going to be very different depending on the underlying OS. For a deep dive into how Windows works, I recommend: Scheduling, Thread Context, and IRQL.

Title: How are blocking calls implemented?

Body: This may be a very simple question. I'm curious how blocking calls are implemented. Specifically, how do they block? Is this just thread.sleep?</p>


问:
Is the output of Eclipse's incremental java compiler used in production? Or is it simply to support Eclipse's features?
I'm new to Java and Eclipse. One of my most recent discoveries was how Eclipse comes shipped with its own java compiler (ejc) for doing incremental builds. Eclipse seems to by default output incrementally built class files to the projRoot/bin folder.

I've noticed too that many projects come with ant files to build the project that uses the java compiler built into the system for doing the production builds.

Coming from a Windows/Visual Studio world where Visual Studio is invoking the compiler for both production and debugging, I'm used to the IDE having a more intimate relationship with the command-line compiler. I'm used to the project being the make file. So my mental model is a little off.

Is whats produced by Eclipse ever used in production? Or is it typically only used to support Eclipse's features (ie its intellisense/incremental building/etc)? Is it typical that for the final "release" build of a project, that ant, maven, or another tool is used to do the full build from the command line?

Mostly I'm looking for the general convention in the Eclipse/Java community. I realize that there may be some outliers out there who DO use ecj in production, but is this generally frowned upon? Or is this normal/accepted practice?

答: It's mainly (and should almost always only) be use for working with Eclipse itself either as an IDE or as a platform. You should always build with the standard production javac that's part of OpenJDK / Oracle's / IBM's Java before deploying.</p>


答:
It would be normal to have a separate build process (e.g. with something like Maven) that does not use the Eclipse compiler which is responsible for producing the final deployable artifacts. For example, in all of my Eclipse Java projects I use:

The built-in Eclipse compiler for quick testing (JUnit), debugging and local execution

Maven to do the "real" builds (full test suite, building deployment artifacts etc.). Here Maven is using the version of the Java compiler that comes with my local JDK.

TravisCI (via GitHub) to do continous integration testing (which also uses Maven, but on remote machines)

You could in theory use the compiled Eclipse class files in production if you want - nothing to stop you packaging these up yourself and deploying them. But this would be a strange thing to do, since it would take a bit of effort and lose you the benefits of having a proper build setup.

P.S. if you want to get good that this stuff then I strongly suggest you invest in learning Maven. It's a steep learning curve but really worth it in the long run.

Title: Is the output of Eclipse's incremental java compiler used in production? Or is it simply to support Eclipse's features?

Body:
I'm new to Java and Eclipse. One of my most recent discoveries was how Eclipse comes shipped with its own java compiler (ejc) for doing incremental builds. Eclipse seems to by default output incrementally built class files to the projRoot/bin folder.

I've noticed too that many projects come with ant files to build the project that uses the java compiler built into the system for doing the production builds.

Coming from a Windows/Visual Studio world where Visual Studio is invoking the compiler for both production and debugging, I'm used to the IDE having a more intimate relationship with the command-line compiler. I'm used to the project being the make file. So my mental model is a little off.

Is whats produced by Eclipse ever used in production? Or is it typically only used to support Eclipse's features (ie its intellisense/incremental building/etc)? Is it typical that for the final "release" build of a project, that ant, maven, or another tool is used to do the full build from the command line?

Mostly I'm looking for the general convention in the Eclipse/Java community. I realize that there may be some outliers out there who DO use ecj in production, but is this generally frowned upon? Or is this normal/accepted practice?