问:
Is embedded programming closer to electrical engineering or software development?
I am being approached with a job for writing embedded C on micro controllers. At first I would have thought that embedding programming is too low on the software stack for me, but maybe I am thinking about it wrong.

Normally I would have shrugged off an opportunity to write embedded code, as I don't consider myself an electrical engineer. Is this a bad assumption? Am I able to write interesting and useful software for embedded systems, or will I kick myself for dropping too low on the software stack?

I went to school for computer science and really enjoyed writing a compiler, thinking about concurrent algorithms, designing data structures, and developing frameworks. However, I am currently employed as a web developer, which doesn't scream the interesting things I just described. (I currently deal with issues like: "this check box needs to be 4 pixels to the left" and "this date is formatted wrong".)

I appreciate everyone's input. I know I have to make the decision for myself, I just would like some clarification on what it means to be a embedded programmer, and if it fits what I find to be interesting.

答:
As an embedded programmer, my job is to make custom hardware work. Typically, I have developed a bunch of software on a dev board, or a previous version of hardware. When the new board comes in, my job is to put my software on the board and demonstrate that everything works.

Because there is almost always a problem of some kind, debugging skills are essential. If the external peripheral doesn't work, is it a bad chip, bad connection to the chip, buggy code or incorrect use of the on-chip peripheral? The only way to tell is with extensive debugging. This means being comfortable with oscilloscopes, network analyzers, logic analyzers and target debuggers. The debugging process becomes almost scientific. I develop a hypothesis, design an experiment to provide evidence for or against my hypothesis, and test.

When evaluating interns or new embedded engineers, this skill is the most critical. All software has problems, but once you start interfacing with the physical worlds, the variety of those problems increases exponentially. The essence of my job is to solve the long series of problems between concept and reality.


问:
Correct For Loop Design
What is the correct design for a for loop?

Felix currently uses

```<code>if len a > 0 do
  for var i in 0 upto len a - 1 do
    println a.[i];
  done
done
</code>```

which is inclusive of the upper bound. This is necessary to support the full range of values of a typical integer type. However the for loop shown does not support zero length arrays, hence the special test, nor will the subtraction of 1 work convincingly if the length of the array is equal to the number of integers.
(I say convincingly because it may be that 0  - 1 = maxval: this is true in C for unsigned int, but are you sure it is true for unsigned char without thinking carefully about integral promotions?)

The actual implementation of the for loop by my compiler does correctly handle 0 but this requires two tests to implement the loop:

```<code>continue:
  if not (i <= bound) goto break
  body
  if i == bound goto break
  ++i
  goto continue
break:
</code>```

Throw in the hand coded zero check in the array example and three tests are needed.

If the loop were exclusive it would handle zero properly, avoiding the special test, but there'd be no way to express the upper bound of an array with maximum size.

Note the C way of doing this:

```<code>for(i=0; predicate(i); increment(i))
</code>```

has the same problem. The predicate is tested after the increment, but the terminating increment is not universally valid!

There is a general argument that a simple exclusive loop is enough: promote the index to a large type to prevent overflow, and assume no one will ever loop to the maximum value of this type.. but I'm not entirely convinced: if you promoted to C's size_t and looped from the second largest value to the largest you'd get an infinite loop!

答:
You forgot to mention wheter your string variables in Felix start with index 0 or 1. Searching for that in the web, its additional job for readers. And affects the way your example is evaluated.

Anyway. Are you sure that:

```<code>for(i=0; predicate(i); increment(i))
</code>```

In C: "The predicate is tested after the increment, but the terminating increment is not universally valid!"

Traslates to this:

```<code>i=0
continue:
  body
  increment(i)
  if not predicate(i) goto break
  goto continue
break:
</code>```

Instead of this:

```<code>continue:
  i=0
  if not predicate(i) goto break
  body
  increment(i)
  goto continue
break:
</code>```

Since your for loop its more specific like pascal, you may consider how should be translated and evaluated in case the index value is equal or lesser to the initial value.

Usually, if the initial value, and final value are the same, the loop is executed once, if the final value is greater that the initial value, the loop is not executed.

ContentLicense: CC BY-SA 3.0

Title: Correct For Loop Design

Body:
You forgot to mention wheter your string variables in Felix start with index 0 or 1. Searching for that in the web, its additional job for readers. And affects the way your example is evaluated.

Anyway. Are you sure that:

for(i=0; predicate(i); increment(i))

In C: "The predicate is tested after the increment, but the terminating increment is not universally valid!"

Traslates to this:

i=0
continue:
  body
  increment(i)
  if not predicate(i) goto break
  goto continue
break:

Instead of this:

continue:
  i=0
  if not predicate(i) goto break
  body
  increment(i)
  goto continue
break:

Since your for loop its more specific like pascal, you may consider how should be translated and evaluated in case the index value is equal or lesser to the initial value.

Usually, if the initial value, and final value are the same, the loop is executed once, if the final value is greater that the initial value, the loop is not executed.


答:
I am not an Electrical Engineer, yet I have done a small amount of embedded software development. The biggest issue I've found is that I have a much more basic background in math, and so I don't know how to easily break down a complex series of advanced mathematical algorithms into code without a lot of help.

For all of the stuff where I've needed to play with signalling, read values from inputs, submit data to outputs, and all that sort of stuff, I've found it little different conceptually to what I do day to day as a good old fashioned Software Developer. Writing software really is what it is.  It's when you need to go out beyond the actual software that I find things getting dicey because I don't have the knowledge to mess directly with the hardware. This  usually happens when trying to debug or test code. If you've got a really great tool chain, you might have integrated debugging and simulation environment to take most of the pain away, yet even with all of that to help you, you sometimes need to get back to basics and test your code against some sort of an analyzer, and the reality is that most embedded platforms don't provide you with the luxury of more than a basic compiler and an EE's Ouija-Board to help you.

From this perspective, I don't think that being an electrical engineer is essential to embedded programming if the tasks are simple, and the actual hardware-specific requirements are minimal.  Beyond that, I think being an EE would make life much easier when working in an embedded environment, particularly when real science is required to figure out where the problems are.

Title: Is embedded programming closer to electrical engineering or software development?

Body:
I am being approached with a job for writing embedded C on micro controllers. At first I would have thought that embedding programming is too low on the software stack for me, but maybe I am thinking about it wrong.

Normally I would have shrugged off an opportunity to write embedded code, as I don't consider myself an electrical engineer. Is this a bad assumption? Am I able to write interesting and useful software for embedded systems, or will I kick myself for dropping too low on the software stack?

I went to school for computer science and really enjoyed writing a compiler, thinking about concurrent algorithms, designing data structures, and developing frameworks. However, I am currently employed as a web developer, which doesn't scream the interesting things I just described. (I currently deal with issues like: "this check box needs to be 4 pixels to the left" and "this date is formatted wrong".)

I appreciate everyone's input. I know I have to make the decision for myself, I just would like some clarification on what it means to be a embedded programmer, and if it fits what I find to be interesting.


问:
How to structure unit tests for a GUI app using C# and NUnit
I've been asked to do a small side-project to supply a simple application to one of our customers. Normally I would be working on back-end code where I have all of my testing needs figured out, and I've not yet had the dubious pleasure of writing tests for the GUI, so it's a little unclear to me how I should set up the testing code and tools for an EXE.

My first instinct was to simply include the tests with the application code, however that would require supplying a number of test-specific dependencies, which I have been instructed to specifically not ship to the customer. I am also unable to squeeze out any cash for a purpose built test tool, so I need to use the tools I have at hand (StoryQ, RhinoMocks, and NUnit), which really should be more than enough to test the behavior of a simple GUI app. So as far as I can see, this leaves me with trying to strike a good balance between keeping the design really simple, or purposefully over-engineering for the sake of the tests. It seems I'm either building the app with the business logic in a separate library and testing against the library as I usually would, or finding some other mechanism to allow me to the executable without breaking out additional modules that the application design doesn't really need.

Edit:

Please note that this question is about how to structure the relationship between NUnit and my executable - as opposed to a DLL - and not about how to separate presentation and business logic.

/Edit

So my question is:

Is there a specific/recommended method for configuring a simple GUI application with unit tests to allow me to adequately check state and behavior, using the tools I have at hand, and without resorting to over-engineering?

Have I missed something fundamental about the way NUnit should be invoked/configured when testing an EXE (as opposed to a DLL)?

Can you provide or point me in the direction of examples of how achieve all of this?

I realize that there may be more than one way to do this so I'm looking for specific implementation guidelines based on your experience.

答:
I mentioned in one of my comments to simoraman's answer that I had thought of a couple of ways to do this. One of my options was similar to the suggestion in Jalayn's answer to created a duplicate project and generate a DLL, while my other idea was to simply link to the files in the project where there was code I wanted to test. While both options could be made to work, they are less than ideal.

In the second case, I'd have a mess of unit dependencies to manage unless I could really tease apart the architecture to minimize dependencies.  This is fine for smaller projects, but larger ones could easily become a real mess to manage. My biggest resistance to this option however is the sheer inelegance of it.  Sure I could get it to work, but in doing so I effectively need to break encapsulation to test the internals of an assembly directly via source, rather than testing the via the public interfaces, which in my mind is a big no-no.  Likewise having an additional project file would mean either duplicating efforts in two projects at a time, or finding a way to add project file settings automatically to two files at a time, or remembering to copy and rename the project field each time I build. This can be automated on the build server perhaps, but would be a pain to manage in the IDE. Again, it can work, but it's a kludge at best, and a nuisance at worse if you get it wrong.

The best way seems to be to do as whatsisname commented to my question, and to simply include the EXE as a reference in the test project. It turns out that an EXE is effectively treated the same way as a DLL in this case, and I am able to access all of my nicely layered classes to test whatever floats my boat.


问:
Is there a unit testing framework for HTML markup?
I work at a web design shop.  Our workflow is divided into two parts: frontend programmers make static html and css templates of the site design, then backend programmers tie the templates into a CMS.

We have a set of common functionality for our sites, and I'm wondering if there's a unit testing framework we can use to test for this functionality.

For example, one of our common functionality guidelines states that all links to a pdf must open in a new window.  I would like to write a unit test that goes something like this

```<code>if(a.class = 'pdf_link')
  assert(target='_blank)
</code>```

Wikipedia's list of unit testing frameworks doesn't seem to have anything that encompasses this relatively simple functionality (checking strings against a template), and I'm leaning towards writing a bunch of bash scripts and tying them into our CI server.

But is there an better way to do this?

答: You need to test the DOM, not the text output.  I don't know what language you are developing in, but in PHP there is PHPUnit, which can do DOM checks.  Look into using assertSelectEquals.  My battery is about to die and I don't have my cord, or I would give you more.


问:
Are enforced Professional Development Plans useful?
Many companies, especially larger ones have mandatory professional development plans for their employees. Employees and managers set out a personalized professional development plan and follow up on the progress every so often.

As a developer, do you find such PDPs useful, do you follow through with your commitments?

As a manager, do you think such PDPs bring value to the company and improve the overall quality of the employees?

It seems that good developers will continue to educate themselves and strive to be better regardless of companies' procedures while bad ones won't.

Are there benefits of having PDPs or is it just something managers feel they need to do?

答:
I have worked for one company that had PDPs.

The problem with the PDPs was that once they were set, there was no time allowed for the development.
So you had to do it on your own time. If you didn't do it, there was no chance of a bonus or raise.
From this experience I decided that the company wants to benefit from  you spending  you own time and money.
Overall I think it is a good thing to develop yourself but not necessarily with targets set by your company.

ContentLicense: CC BY-SA 2.5


问:
How should I deal with nested compositions?
I came across the following question on a website for interviews:

Here are 3 products: table, chair and bench. Product can be of material: wood, metal, and plastic. Design class structures for this.

My first thought was to have an abstract class Product with a protected Material class member as shown below. My actual question is after the code block below

```<code>#include <stdio.h>
#include <string>
using namespace std;

class Type {
    public:
    // Commented out virtual below. Was a typo !
    /*virtual*/void SetType(string s) {
        m_typeName = s;
    }
    virtual void PrintType() {
        printf("Type = %s\n",m_typeName.c_str());
    }
    virtual ~Type()=0;
    Type& operator=(const Type& rhs) {
        if ( &rhs != this ) {
            m_typeName = rhs.m_typeName;
        }
        return *this;
    }
    private:
    string m_typeName;
};
Type::~Type() {}

class Wood: public Type {
};

class Plastic: public Type {
};

class Product {
    public:
    Product():m_type(NULL) {
    }
    virtual void SetType(Type* t){
        m_type = t;
    }
    virtual void PrintInfo() {
        printf("I am %s product\n",m_productName.c_str());
        m_type->PrintType();
    }
    virtual ~Product()=0;
    protected:
    string m_productName;
    Type* m_type;
};
Product::~Product() {}

class Table: public Product {
    public:
    Table() {
        m_productName = "table";
    }
};

class Chair: public Product {
    public:
    Chair() {
        m_productName = "chair";
    }
};

int main()
{
    Plastic *p = new Plastic();
    p->SetType("plastic");

    Table *t = new Table();
    t->SetType(p);

    t->PrintInfo();

    delete t;
    delete p;

    return 0;
}
</code>```

However, I have a feeling it could be designed better.

In general, if your compositions (Product in the example) contain compositions (Material in the example), what is a good design pattern?

答:
From how you formulated that question, I do not see any indication that a concrete C++ program was requested. As such, as an interviewer, I'd be immediately suspicious if a candidate would give me any source code whatsoever in an attempt to answer the question.

I can only assume that the question itself contains insufficient requirements on purpose, because it's part of our everyday lives. You have to be able to a) identify the lack of requirements and b) discuss different options.

In summary, the whole interview question is probably intended to find out if the candidate can talk about class diagrams and mentally dissect different alternatives for solutions. What I'd expect from a good candidate would be a quick draft of a class diagram (f.ex. in UML, though not necessarily) and lots of questions.

Any source code being written at this point would score negatively for that matter.

OwnerDisplayName: curryage


问:
How do you respond to "Tell me a little bit about yourself." question in interviews?
I've been asked this in a few interviews. And it always catches me off guard.My professional and academic background are already in the resumé, which the interviewer has obviously looked at. What more to tell him/her? Should I start with my hobbies? I like gardening, or looking at NSFW pictures on reddit in my free time?

What and how do you answer to this specific question? Do you have a prepared answer for it? Am I wrong if I think this question is a bit silly?

UPDATE There have been a lot of great answers to this question. I'm in pickle which to choose as the 'correct' answer, because most of them are very insightful. I found a great writing on this subject matter. It's a bit crazy for my taste, but it's interesting:

How To Introduce Yourself… I Mean Practically

答: This is the classic underhand softball pitch question for you to sell yourself and hit it out of the park. It's similar in spirit to "why should we hire you", which people also tend to fear if they don't know it's an easy question. You should be prepared for it and have a prepared answer. It should restate some of what's on your resume while also hopefully telling something unique about you. For example I have two undergrad degrees, one liberal arts and the other computer science. Explaining how that happened entails me saying at some point that I realized I love to write code and I was willing to go back to school and redo my degree while working full time to make it happen. It turns out that hiring managers like to hear that kind of thing. So tell them what's unique about you that will make them want to hire you. That's what the question is about.</p>


问:
Adding ordered nodes to tree in arbitrary order
I have a database of nodes.  Each node can have exactly one parent, but any number of children.  Some nodes may be stored with no parent, but at run time, I can create a default "root" node to be the parent of these.

First off, what is this data structure called?  I think it's just a "tree," but I want to make sure I'm using the correct terminology.

Another issue I'm running into is finding an efficient way to create the tree.  The nodes can be retrieved from the database in any order, so when I add a node to the tree, its parent may not be in the tree yet.  This means that when I add a node, I have to check whether any existing nodes have parents and then add the parent in the appropriate spot.

I've searched a lot online, but most talk about trees just refers to "binary trees," and even then I can't even find any good examples of constructing the tree in code -- it's usually working with an existing tree.

Are there any examples of efficient ways to build this tree (whatever it may be called)?  Language doesn't matter, but I'll be using php.

答:
Your definition is insufficient for a tree. Simply enforcing that each node has exactly one parent is in fact far from a tree, because it already guarantees your structure will be cyclic.

A tree is a directed graph without cycles, in which any two vertices are connected by exactly one (simple) path. If you leave out the simple path requirement you end up with a more general structure, called the directed acyclic graph. If you further allow cycles, you get a directed graph, which is pretty much what you have given your simple description.

Independent of whether the definition of your data nodes you gave is exact or not, you may do best by assuming a directed (acyclic) graph for your construction process. In a graph, standalone nodes that are not (yet) connected are a normal case that won't give you any trouble. So you can read out the database in any order you want to and construct your datastructure from that.

Edit: I already assumed that your structure is acyclic. But do note that any tree is also a special case of a graph, so the above all holds. Do read up on graph datastructures, as they allow you to construct trees in an incremental fashion, without requiring proper roots and children all the time. You only have to guarantee, that the final graph will indeed be a tree structure (which mainly depends on your database content).


问:
How to stop the development spec from changing in mid development?
Problem: It seems with almost every development effort I'm involved in, no matter how much time is spent planning prior to starting development, there is always a large amount of changes required either midway or towards the end of the project. These are sometimes big changes which require alot of re-development.

I don't work for clients who pay money, this is an in-house development team on in-house development websites. So, it's not like I can charge for it or anything. And at the end of the day, we have to try to hit deadlines.

Questions: What are some of the best ways you guys have found to minimize and prevent spec changes from cropping up midway or after development?

答:
For me it's quite easy.

Tell the one, the "Product owner", who have ordered the features that this is OK, but he have to choose a couple of planned feature he could be without for this deadline.

Think of it as a half sprint meeting with the PO where you tell him that the sprint wont burn down to 0.

Ps. If it's not the "PO" I would say don't talk to me go thru the "PO"


问:
When to stop writing user stories, and start coding?
When discovering stories for the first sprint, how do you know when to stop writing and move forward?

I've asked a few people I know, and basically the response I've gotten is, it depends on the context the project exists in and how timeboxed the overall project is as well.

Is there any standard way for knowing when to stop writing user stories, and if so, what is the basis for this, and how does it apply to future sprints?

答:
The two activities are not antagonistic.

Story writing is about defining the desired needs under the constraint of providing business value.

Starting to code happens in the middle of a sprint. To start a sprint, the only prerequisite is a defined sprint backlog - priorized by the PO  (the story writer) and selected by the team.

You should stop writing stories (=stop the project), when the marginal benefit af implementing the story versus the cost of implementation and actualized operating cost of the defined function is négative.

You should start to code in the context of a sprint, when the story is understood (analysis) and the testing and implementation are defined (design) - the classical software development approach.


问:
Efficient Java Programmer
There's been a buzz in my local tech community about being an 'Efficient Java Programmer' can someone explain to me what is an Efficient Java Programmer? what is their difference between average java programmers? how can you be an Efficient Java Programmer? (I am still in college, I want to get acustomed to doing the proper practices when it comes to programming) and how can you tell someone is an efficient java programmer?</p>

答:
Efficient could mean anything... my guess is:

Know and use the libraries (instead of reinventing the wheel)

Use an IDE (Eclipse, NetBeans, whatever fits you)

Use version control (okay, not so Java specific)

Know advanced features (concurrency, generics)

and many more...

Title: Efficient Java Programmer


问:
What can one do when "lead by example" doesn't work?
I have been working for a big company (8000+ employees) for almost 2 years now, and was hired just after I finished my study course.

Everyone here has to deal daily with legacy code which is often very badly designed and full of hacks. At first, I kept a low profile, trying not to criticize things too much. But the situation, as it stands, has become very difficult to live with and it seems no one is willing to improve/replace the tools we use.

To be more explicit we have:

An obsolete source control tool (Visual SourceSafe)

Plain old makefiles which only support full rebuild

.def files which must be maintained manually and separately for all existing architectures

monolithic headers files and projects with very few different files (but each has around 3000 lines of code, which sometimes takes care of very different tasks)

no use of the "new" languages facilities (well std::string is not that new but nobody except me uses it)

I decided, a few months ago to do something about it, by designing a new compilation environment. I could get incremental builds to work reliably, faster compilation times, better structured projects, automatic .def files generation. I even created a bridge from/to Git to/from Visual SourceSafe.

I showed my achievements to several collegues and our boss but it was like nobody cared. They were all like "Well... people are used to do it that way now. Why would we change things ?"

The changes I suggested were designed so that we could have a soft transition from the old system to the new one. Each improvement could be applied separately and safely.

I even tried to get some of my coworkers involved in the changes. But so far, no success.

Have you already faced a similar situation ? What can one do when "lead by example" doesn't work ?

答:
Sadly people get stuck in a rut and develop the mentality that 'it works, everyone uses it okay, why change it' And it gets infuriating.

You have gone about it the right way by not just complaining but by developing a workable solution as a replacement, now you just need buy-in.

Show your direct line manager (or technical lead).  If they are uninterested, do you have anyone in charge of change control or innovation?

Potentially though, your ideas and work could be ignored and the situation will stay as it is.


答:
You need to state your case in a way that get your boss on your side. BTW, This kind of change is proposed by a technical director or project manager, so will need to commit yourself to the project. (As an alternative route, you can propose a technical audit, an outsider is likely to say the same things as you but will have more weight.)

So far, he doesn't see the need to change, it looks like cosmetics change to him : Costly without obvious benefits except to satisfy the fancy of a dev. Only two things matter to him : the flow of money and a stable team. The tech is a black box, if it works, that's enough.

First money, you need to proove that the current setup is costing him money. What the cost/hour of a dev and how many hours faster compilation times would save him ? Do the math. Also, compile articles or testimonies about the risks of the current code pipeline and show him scary numbers : "because of SourceSafe/Bad Coding Practices, our company lost $XXXK".

Second the team, your boss may be stuck with old grumpy coders who don't want to change their ways. If the first point is established, you also need to propose a solution to this problem. How many are you ? It could interesting to underline that it will hard to replace someone because the current coding pipeline is bizantine. You need to propose a plan to update the team. Learn them the industry best practice and check they are following the new rules.

Finally, you need to propose a plan to change the codebase, divided into small projects, with milestones and resources allocation. In fact, you're selling yourself as a project manager and the changes as mandatory to have a solid code pipeline.

Title: What can one do when "lead by example" doesn't work?

Body:
I have been working for a big company (8000+ employees) for almost 2 years now, and was hired just after I finished my study course.

Everyone here has to deal daily with legacy code which is often very badly designed and full of hacks. At first, I kept a low profile, trying not to criticize things too much. But the situation, as it stands, has become very difficult to live with and it seems no one is willing to improve/replace the tools we use.

To be more explicit we have:

An obsolete source control tool (Visual SourceSafe)

Plain old makefiles which only support full rebuild

.def files which must be maintained manually and separately for all existing architectures

monolithic headers files and projects with very few different files (but each has around 3000 lines of code, which sometimes takes care of very different tasks)

no use of the "new" languages facilities (well std::string is not that new but nobody except me uses it)

I decided, a few months ago to do something about it, by designing a new compilation environment. I could get incremental builds to work reliably, faster compilation times, better structured projects, automatic .def files generation. I even created a bridge from/to Git to/from Visual SourceSafe.

I showed my achievements to several collegues and our boss but it was like nobody cared. They were all like "Well... people are used to do it that way now. Why would we change things ?"

The changes I suggested were designed so that we could have a soft transition from the old system to the new one. Each improvement could be applied separately and safely.

I even tried to get some of my coworkers involved in the changes. But so far, no success.

Have you already faced a similar situation ? What can one do when "lead by example" doesn't work ?


答:
In addtion to Lionel Barret (which I mostly agree), consider also the possible motivation to the resistance.

Evaluate the cost of the actual process

Evaluate the cost of the process as it will be like yours

But also:

Evaluate the cost of the change in term of

Money to spend to setup the new environment for anyone

Time to spend to train everyone to be accustomed to the new mode (it may be easy for you, but not that easy for people who are not aware of what you are doing)

Elapsed time required to manage the change in a non-disruptive way.

I have a suspect: How many are in your company the people like you in term of age and culture (I men "school" and "type of school")?
How many people like you are expected to be hired in the next 2/3 years and how many will retire or change their role in the organization?

My suspect is that you are in a position with not enough strength to change the company.
In that situation, either the company will change you or will "expel" you (In the sense it will become your own wish to go away), if you're not able to wait for more time.

But may be the company is evaluating that the additional costs I told you can be saved allowing the change process to happen spontaneously by waiting the natural replacement of the people to happen.
You're just at the beginning of a process you cannot see because has nothing (yet) behind you.


答:
Aim for the head: "Lead by example" should have improvement in mind, but it should be targeted on people not on technology. Maybe you have invested too much time in improving technology, but not enough time in what is going on in their heads. Think about the driving factors why there is an opposition for new things. In many cases they just fear some risk. Identify those risks and find counterarguments for them.

Grab the fresh meat: It is easier to win over employees who want to change things. You notice them immediately when you see them.

Avoid the rotten meat: Some will never sympathize with your ideas. Leave them aside.

Grow to a critical mass: Find people who sympathize with your ideas. Win the over one by one. At some point if a critical mass is reached, more and more people will follow your example voluntarily.

Management vocabulary: Managers are not interested in better designs. Their language is money and time. Make clear how much man hours are wasted for bugs. Make clear that unsatisfied customers who encounter bugs are not profitable. Demonstrate how much faster you can implement a new feature. You need to choose another vocabulary for managers.

It is all about processes: Better technologies do not make better programmers and programs. If you have good running processes, even outdated technologies lead to good results. Think about were effort and time is wasted. Maybe it is not the technology, but something in the processes is going awfully wrong. In most cases it is a lack of communication.

Find a new company: You already have done a lot. You can still try to improve things, but it is also up to you to decide how long you want to try it and how much energy you want to invest. Keep in mind: Even if you cannot achieve a lot of improvement, you will learn a lot out of your efforts. At some point you need to move on.


答:
For me an efficient Java Programer has the following attributes.

Knowable of:

Computers in general: e.g. Understand a proxy to set up an application that needs access to several different networks thru for example VPN.

Exotic but simple tricks like in memory caching.

Different frameworks, Java is nothing without it's vast framework and external APIs. For example reason the choice of a controller (Play, Spring MVC or Struts). Few things is wore than fossil developers that choose historic frameworks because they have years of experience with it.

People skills, know how to work in a team and sometimes resign to inferior solutions for the team to be happy. The mindset that the job should be fun and not work.

Write code that is easy for the team and new members to understand.

Have basic sense of economics. For example don't write complicated code to optimize performance when you could fix that for 1000$ in hardware instead. Lets say you cost 100$ an hour and you spend 2weeks making shit spaghetti code that is optimized and cant be adapted to CRs that will come.

Don't be afraid of management and project leaders. You are the expert not them. Get involved in management questions. For example say and repeat that you need 3 month development freeze each year to focus only on refactoring. Many developers are conflict afraid chickens, they know what's the best but are afraid to motivate it.

Title: Efficient Java Programmer

Body: There's been a buzz in my local tech community about being an 'Efficient Java Programmer' can someone explain to me what is an Efficient Java Programmer? what is their difference between average java programmers? how can you be an Efficient Java Programmer? (I am still in college, I want to get acustomed to doing the proper practices when it comes to programming) and how can you tell someone is an efficient java programmer?</p>


答:
I am wondering if perhaps something like Selenium would do the trick? Its a testing mechanism that is run on behavioural driven development. It can run through UI actions so that you confirm if they are correct or not. Note that I haven't used it a lot but when I did it seemed really useful.

Selenium Homepage

Title: Is there a unit testing framework for HTML markup?

Body:
I work at a web design shop.  Our workflow is divided into two parts: frontend programmers make static html and css templates of the site design, then backend programmers tie the templates into a CMS.

We have a set of common functionality for our sites, and I'm wondering if there's a unit testing framework we can use to test for this functionality.

For example, one of our common functionality guidelines states that all links to a pdf must open in a new window.  I would like to write a unit test that goes something like this

```<code>if(a.class = 'pdf_link')
  assert(target='_blank)
</code>```

Wikipedia's list of unit testing frameworks doesn't seem to have anything that encompasses this relatively simple functionality (checking strings against a template), and I'm leaning towards writing a bunch of bash scripts and tying them into our CI server.

But is there an better way to do this?


问:
Difference between a service class and a Helper class
I would like to know what differentiates  a Service class from a utility class or a helper class?
A class only with underlying methods calls the dao's is a service? Doesn't the usage of Helper classes violates SRP?</p>

答:
The lines can be a little blurry, but I see it this way:

A Service class/interface provides a way of a client to interact with some functionality in the application. This is typically public, with some business meaning. For example, a TicketingService interface might allow you to buyTicket, sellTicket and so on.

A helper class tends to be hidden from the client and is used internally to provide some boiler plate work that has no business domain meaning.  For example, let's say you wanted to convert a date into a timestamp in order to save it to your particular datastore. You might have a utility class called DateConvertor with a convertDateToTimestamp method that performs this processing.

Services are not simply tightly coupled to DAOs, it's a broader term/usage pattern than persistence

Helper classes do not violate SRP if coded in accordance with that principle.  That is, each method should do one thing and one thing well, the class should perform one type of utility help, (e.g. Date conversion) and do that well.


问:
What is the value in hiding the details through abstractions? Isn't there value in transparency?

Background

I am not a big fan of abstraction. I will admit that one can benefit from adaptability, portability and re-usability of interfaces etc. There is real benefit there, and I don't wish to question that, so let's ignore it.

There is the other major "benefit" of abstraction, which is to hide implementation logic and details from users of this abstraction. The argument is that you don't need to know the details, and that one should concentrate on their own logic at this point. Makes sense in theory.

However, whenever I've been maintaining large enterprise applications, I always need to know more details. It becomes a huge hassle digging deeper and deeper into the abstraction at every turn just to find out exactly what something does; i.e. having to do "open declaration" about 12 times before finding the stored procedure used.

This 'hide the details' mentality seems to just get in the way. I'm always wishing for more transparent interfaces and less abstraction. I can read high level source code and know what it does, but I'll never know how it does it, when how it does it, is what I really need to know.

What's going on here? Has every system I've ever worked on just been badly designed (from this perspective at least)?

My philosophy

When I develop software, I feel like I try to follow a philosophy I feel is closely related to the ArchLinux philosophy:

Arch Linux retains the inherent complexities of a GNU/Linux system, while keeping them well organized and transparent. Arch Linux developers and users believe that trying to hide the complexities of a system actually results in an even more complex system, and is therefore to be avoided.

And therefore, I never try to hide complexity of my software behind abstraction layers. I try to abuse abstraction, not become a slave to it.

Question at heart

Is there real value in hiding the details?

Aren't we sacrificing transparency?

Isn't this transparency valuable?

答:
The guiding purpose of hiding and abstraction should be decoupling the user from the implementation so they can be changed independently If the consumer is coupled with the implementation details, due to fiddling with their internals both are cast in stone and it becomes harder to introduce new features or better algorithms in the future.

When writing a module, hidden parts of the implementation gives you the piece of mind to be able to change them without risking breaking other code you can't think of.

Another advantage to providing opaque interfaces is that they significantly reduce the surface area between subsystems. By reducing the amount of ways they can interact they can become more predictable, easier to test and have fewer bug. Interactions between modules also increase quadratically with the number of modules so there is a value in trying to control this growth of complexity.

That said, it is of course possible to hide too much and nest interfaces too deep. It is the job of the programmer, as an intelligent human, to design the system so that it is maximally useful while also minimizing complexity and maximizing maintainability.


答:
You mixed up two non related principals. Services and Helper-Classes are not connected. Especially the term "Service Class" is misleading - I think you are referring to a "Service" which is on a higher level of abstraction than classes. A service is characterized through

"a mechanism to enable access to one or more capabilities, where the
  access is provided using a prescribed interface and is exercised
  consistent with constraints and policies as specified by the service
  description."

This definition slightly changes depending on your context. However, the critical point is that the term "service" is on an abstract level, the level of architecture and domain knowledge. The "Helper Class" is a design pattern (even though it's a anti-pattern as they tend to evolve to blob's or god classes) referring to a class that encapsulate generic operations (notice that this is on a lower level of abstraction and is connected to the application/solution knowledge). I'm aware of the fact that there exists nearly no software not containing any kind of helper class, but still, it's bad practice.

Title: Difference between a service class and a Helper class

Body:
I would like to know what differentiates  a Service class from a utility class or a helper class?
A class only with underlying methods calls the dao's is a service? Doesn't the usage of Helper classes violates SRP?</p>


答:
For me, I go by the Eric Evans definition of service which is something like this:

Generally, in a well designed system, most classes (in the Domain Model) have quite clear responsibility or function in that they deal with a specific entity or set of entities in the model.

i.e.

Account, Account Factory, Account Repository, etc

Customer, Customer Factory, Customer Repository, etc

When you have functionality that does not belong with any particular entity it can be difficult to find a correct place for it to sit. I.e something that encapsulates a process that involves both an Account AND a Customer .

So, that's where a service comes in. It's where you put code that is in the Domain Model but does not naturally belong to one entity/component or another.

I think of a helper as a kind of strategy class. To me its a place to put code that needs to be re-used by various classes but might not quite sit well as abstract methods inside the hierarchy of the classes who use it. Personally I find the term helper a bit vague and don't really have them in my model. Although they exist in libraries that I use.


答:
Have you ever stopped to consider that you might be wrong?

So you read some designs and patterns books in school and you are disenfranchised with what seems like comparitively antiquated practices where you work.  No doubt they are probably better ideas and new projects should start with these in mind, but it seems like you are on a completely different level.

Herding developers is like trying to herd cats, they inherently have a mind of their own, and a preferred way of doing things, whether right or not.  I have a hard enough time enforcing best practices and managing a team of 2 developers, but you work for a company that has 8000.

That is a staggeringly huge number.  Even a simple process change that states all developers must schedule meetings and out of office time on the public calendar becomes an enormously complex and difficult policy to implement across the board.  It would also require a significant push from management to make sure the policy is accepted and adopted across the board.

You may not think it, but something as simple as moving from monolithic to multiple header files, or moving version control from SourceSafe to Git requires an enormous effort and investment on the part of everybody involved.  It would require:

Significant management support

Company wide acceptance

Investment of meeting hours for all developers to inform them of the new initiatives (Meetings cost man hours, man hours cost money)

Training needs to be planned and established to make sure even the stupidest developers know what they are doing

Even assuming an hour of training, across 8000 developers x €50/hr = €400000 cost of training.  This is more money than my one software development team gets budgeted in an entire year for salary, software and hardware.  That is an exceptional investment you are proposing.

But you are saying, "Think of all the time that could be saved through productivity increases."  Rightly so, but significant investment is significant risk, so I better be damn sure that you are right about this before I sign off on it.  If none of the senior guys are backing you then I can't justify the expense.  Ultimately we may be inefficient, but we are consistent and with 8000 developers across the company, consistency is the most important.

To do this you need sign off from multiple senior level people, and you need to accurately and objectively find a way to measure lost developer time to inefficiency.  That time equates to dollars and only dollars and politics will help you win this battle.


问:
Two different user story forms, are both correct?
Just ran across this user story form:

```<code>"As a <user role>, I can <activity> so that <business value>"
</code>```

(source-1 and source-2)

which to me seems different than what I believe to be the "standard" one:

```<code>"As a <role>, I want <goal/desire>, so that <benefit>"
</code>```

(source-1 and source-2)

(Meaning that I'd believe "I can" would be in the "benefit/value" statement, not the "goal" statement. For example, "So that I can [...].")

Are both right, or is one flawed, and why?

答:
Logically a user story is describing something that the user currently can't do, otherwise there would be no need to implement anything. So wording "I can ..." does not make sense in the goal/action part. Most logical wording is "I want ...". I can imagine wording "I (will) do ..." (more like use case wording).

For action vs. goal/desire, a goal can easily be do action. So the "goal" template is more generic, though I can imagine it often will end up describing an action anyway.


问:
What are build team responsibilities from developer point of view?
Lets assume that you are working for a corporation doing a lot of IT development.

What do you think should be build team responsibilities that performs 'services' for developers?
What do you expect to be doing by yourselves and what tasks would you gladly pass?

答:
I would like fast build times.

I would like other devs build integrated fast if you have integrators. For example not two weeks integration time for different modules. I if a team has made a module it should be integrated fast.

If the build team are competent I would like them to understand the code and write the build scripts as a developer I hate this things. But most probably I wouldn't trust a build guy. For example we had a build guy how understood programing in one project so he made all the targets in the build files including compressing JavaScript and so on, this is a blessing but I think such a competent person is overqualified for build.

I expect them to have a nice homepage with statistics and downloadable builds.

I expect them to notify the developers who breaks the build. And like if they provided hints to why, especially if it's related to the build system.

tl;dr I want to type git push and have everything taken care for me. And some kind of "semi-atomatic" dependance update.


答:
What you've described doesn't sound like "lead by example" to me, it sounds like you made a proposal and were rejected.  To lead by example you need to show people that your way is better.  Of the problems you listed I see three that you can start using your own changes yourself.

Plain old makefiles which only support full rebuild.

Create your own makefiles locally and show how much more efficiently you're able to work with them.

monolithic headers files and projects with very few different files (but each has around 3000 lines of code, which sometimes takes care of very different tasks)

Either break up existing ones when you touch them (without breaking the build) or introduce smaller header files when you write new code.  As people start to work with them, they'll realize they don't need the duplication.

no use of the "new" languages facilities (well std::string is not that new but nobody except me uses it)

Continue introducing new language facilities any time you touch old code or introduce new code.  Make sure you're simplifying things.  Don't be discouraged from this one.  Most of us are lazy.  If we see that a new language feature makes things easier, we'll adopt it.

After a few months, if other developers start adopting your improvements, then you can approach your boss again about more radical changes like upgrading your source control system.  You need to make sure the other developers see the benefit though, or it will never go through.  One way to approach it might be to suggest trying out Git on a small project that only a few developers are active on.  That way you can promote it as an evaluation, not a full scale transition to an unfamiliar system.

Finally, if after several months of trying no one seems interested in improving how things are done at your company, you need to really consider whether it's a good fit for you.


问:
Can the ScrumMaster and other team members be managed by the Product Owner?
Our team is switching to Scrum. I would be the ScrumMaster (in addition to being a developer), and another developer would become Product Owner (in addition to our product marketing guy).

All members of the team, including me, would be managed by the would-be Product Owner. By that I mean that the guy would be the one deciding about our yearly evaluation, raises, etc. Would this hierarchical link be prone to introduce issues? How do organizations typically map hierarchical structure onto agile teams?

I suppose it's quite common that the ScrumMaster has a hierarchical link to the other developers in the team.  Here it would be the Product Owner.  Is this different?

答:
The product manager doesn't manage the team, but the product backlog. Having any hierarchical link will make things harder.

I also suggest you to remove yearly evaluations from your company. They are individual, and Scrum is focused on a team rather than individuals.

There is no hierarchical link between the Scrum Master and the rest of the team. The team is self managed.

The ScrumMaster ensure that the scrum process is properly implemented and help the team on a daily basis.

The team reports to the team during the daily stand ups.

The team reports to the product owner during the sprint review.

Simple and effective.


问:
How can I defend Ruby on Rails against customers' not technical opinion?
My customer, a translations business owner, just told me that he has been reading about Ruby on Rails and told me that "there are more PHP guys around there" and "it seems the community prefers it".
What would you, as software engineer and freelancer, say to the customer to achieve these goals:

Sell

Make him see that the technology is my expert decision and Rails
is as good or better than PHP (+ whatever framework) for this
particular project.

UPDATE:
Thank you all for the suggestions! Tomorrow I've got another meeting with him, let's see how it goes, I will update again :)

UPDATE 2:
Finally I told him to read this thread and the result has been fantastic: He gave me the project and we are going to start right now. Thank you all for the help, you have free beer in my charge if we see someday :)

BTW: I learned the lesson: be as transparent as possible, because if you believe in yourself and your work, there is no question compromising enough to beat you.

regards

答:
Surely this is a business decision for both of you.

For you the questions are:

How much will it cost me to implement my customers requirements using Ruby on Rails?

How much will it cost me to implement them in PHP?

What value do I place on using my preferred environment?

For your customer, the question is

How much are the perceived benefits of PHP over Ruby on Rails worth to me?

If you provide your customer with a quotation with a Price for implementation using Ruby on Rails and a separate Price for implmentation using PHP, both based on the answers to your own questions, then your customer can make their own judgement call as to whether the extra cost now is worth possible future savings.

This is no different to them making a decision as to whether they should give the contract to you, or to another developer who would implement it using PHP as requested.

OwnerDisplayName: okeen


问:
Load testing : how to generate per second requests?
I have a server component which runs over Zeroc-ICE. When I wanted to load test it, I thought that using parallel library to create multiple requests would do it. But it dint end up that way. Using Parallel(Parallel.For) library from C# apparently was easier but it doesn't seem to be exactly generating everything parallel in the same instant. So it cannot be the definition for creating N requests per second. How should I do it ? I guess anyone who wants to do load testing first would actually think about this .

What's the efficient way to actually create N requests in really per second ?

Another myth is about the parallel programming. Please enlighten us , if you have used parallel programming patterns in C# or .Net in general . Imagine I have 5 processes. How will start all the five processes at the same time. What does it mean to my consumption of resources ? I have tried reading into many of the material available over the net but I get more and more questions than them being the answer to my questions.

I used Parallel.For and created N threads and measured time. Then I tried the same thing using Task.Factory.start for enumeration of tasks. The time measured was different. So What exactly is the different between using these ? When I should use the corresponding classes and for what purposes exactly ? we often have lots of riches but its just we exactly don't know how to differentiate one from the another. This is one such case for me, not being able to find why I should not use one from the another.

I used the stopwatch class to measure these times which claims to be the best. In the scenario of me load testing a component, what would be the way to measure the time of response. Stopwatch seems to be the best solution for me . Any opinions are welcome.

ps: There are many load testing tools for web applications. Mine is a customised case of server components. And my question is more pertaining to creating N threads per second.

All opinions are welcome. Just don't think its so much not a programming question. It ofcourse is. It should ring bells for any programmer who wants to QE stuff by himself to know the performance of his product , first hand by himself.I have tried many options and then had to fall back on how should I actually do it ?

答:
The easiest way to achieve load testing for any .NET project is to purchase the Ultimate edition of Visual Studio. This comes with an integrated testing tools to help preform all kinds of tests including load tests. Load tests can be preform by creating virtual users either on a single PC or distributed across several for larger numbers of users, there is also a small program that can be installed on the target servers to return additional data for the duration of the test.

This is expensive though, but the ultimate edition comes with a lot of features, so if all were used it would be a more reasonable price.

OwnerDisplayName: King


问:
Help me understand how to stream video
I'm an experienced PHP web developer that is looking to understand the options available for streaming video.

What I have: a video processing system (this one) that can provide output to various streaming servers / CDNs / HTTPs.

What I want: the ability to embed streams on multiple sites, with the ability to enable/disable the stream based on the visitor's session.

What options exist for meeting these requirements? Feel free to be broad or recommend reading, as I have a relatively low understanding of this field. I'm open to both paid services as well as implementing some of this myself. Low cost is of relative importance.

答:
The easiest way would be to just use a paid service to handle the video delivery. The big guys in that space are Brightcove and Ooyala. Expect to pay tens of thousands, especially if you want custom authentication. Viddler is a new interesting option that is trying to penetrate the market and might be a good fit. That said, you can probably more effectively buy than build in this space -- it is pretty complex, and there are lots of fixed costs (delivery) and it is a pretty technically difficult problem. Moreover, the services make it alot easier to monitize your content as they connect with ad servers and provide analytics, which are even more of a bear to effectively build. Finally, in 2012, mobile is key and I'd rather not solve the problem of mobile-friendly transcoding and mobile delivery myself.

If you do need to build it, you'll probably want to look at using a streaming server such as Flash Media Server of Wowza in conjunction with a CDN (Akamai or Limelight come to mind) to deliver the bits. IIRC, most streaming servers have some authentication bits you can ride. You would most likely have to integrate your authentication store over a web service of some sort.

Finally, if you haven't caught the drift, there is no such thing as low cost when it comes to effectively delivering non-public video. For public video use Youtube.

Title: Help me understand how to stream video


问:
What alternatives are there to using HTML/CSS layouts for websites?
Is there any existing in-use, or even just conceptual attempts at creating a markup or programmatic expressions for designing the layouts of websites other than HTML/CSS?

If there are others out there and they do not appear to be in heavy use. Why is this?

答:
Moderator note: this is intended to be a canonical list; please check to see if your suggestion has already been added to the answer. If it hasn't, edit the answer to add yours preferably with an explanation or reason why you're suggesting it.

Possible alternatives:

Adobe Flash (via Martin Beckett)

AXR specification

HAML (via galador)

Java Applets

JavaScript using the <canvas> element (via Czarek)

PDF — Supports hyperlinks (via Peter Taylor)

SASS (via galador)

Sencha Ext JS 4 — has a number of good layout managers and containers, and the code to define those can be defined in a quite declarative manner similar to the JSON format (via herzmeister)

Silverlight XAML (via Emmad Kareem)

XSL/XSLT (via ben)

SVG


答:
I usually will respond asking for parameters on an answer, mainly with time and focus being key points.  Does the interviewer want just 30 seconds or do I have 15 minutes to answer the question?  Does the interviewer want to know about my qualifications, the story of my life, or something else?  There are more than a few different ways I could see wanting to approach to answer this question and thus I'd get clarification before jumping off and shooting off my foot which is quite probable.

If you consider the question to be a test of dealing with ambiguity then you may understand how the question isn't silly at all.  For example, would you describe your dreams at this point or do you stick to your history?  Do you focus on current skills or desired skills?  There are more than a few different ways to answer the question and whichever is chosen there may be various inferences made.  For example, do you stick to business here or do you give a story from left field that could be seen as rather irrelevant here?  Just to give an example here, I could state that I'm quite emotionally sensitive as an answer that may get an eyebrow raise or worse as this isn't what the interviewer really wanted to know yet I believe it is a valid concern to raise at some point.

Title: How do you respond to "Tell me a little bit about yourself." question in interviews?

Body:
I've been asked this in a few interviews. And it always catches me off guard.My professional and academic background are already in the resumé, which the interviewer has obviously looked at. What more to tell him/her? Should I start with my hobbies? I like gardening, or looking at NSFW pictures on reddit in my free time?

What and how do you answer to this specific question? Do you have a prepared answer for it? Am I wrong if I think this question is a bit silly?

UPDATE There have been a lot of great answers to this question. I'm in pickle which to choose as the 'correct' answer, because most of them are very insightful. I found a great writing on this subject matter. It's a bit crazy for my taste, but it's interesting:

How To Introduce Yourself… I Mean Practically


答:
The product owner should, ideally, be part of the team in exactly the same way as the others. It's also got nothing to do with admin tasks. The scrummaster should be owning the process and ensuring the technical side is on track, the product owner should be ensuring that what the team is up to is matching what the business needs and that it isn't getting bogged down in technical tangents not relevent to the project. There is a natural tension there, which is why it's generally better not to combine them into one person. I find the closest parallel to PO in a traditional setup would be something between Business Analyst and project manager - but much, much closer to BA than PM.

Obviously you'll need to do reporting, and also the admin tasks - but don't get them mixed up with the scrummaster and product owner roles (even if those are the people doing them).

In our team we rotate the scrummaster role every couple of months (or when it looks like someone gets bored of it). I'm the development manager where I work (but I also take an active part in coding) - but that doesn't necessarily mean that at any one time I'm SM. I find that emphasises collaboration over hierarchy and once you're comfortable with scrum I suggest you do the same.

Title: Can the ScrumMaster and other team members be managed by the Product Owner?

Body:
Our team is switching to Scrum. I would be the ScrumMaster (in addition to being a developer), and another developer would become Product Owner (in addition to our product marketing guy).

All members of the team, including me, would be managed by the would-be Product Owner. By that I mean that the guy would be the one deciding about our yearly evaluation, raises, etc. Would this hierarchical link be prone to introduce issues? How do organizations typically map hierarchical structure onto agile teams?

I suppose it's quite common that the ScrumMaster has a hierarchical link to the other developers in the team.  Here it would be the Product Owner.  Is this different?


答:
I am in the enterprise application business too, and this question grabbed my attention because I have the same question myself. I had some insight regarding the abstraction issue over the course of my career thus far, but my insight is by no means the universal answer. I am continuing to learn/listen to new ideas and thoughts, so what I believe now may change.

When I was a maintaining a large and complex healthcare application, just liked you, I hated all the abstractions there. Figuring where the all the code goes was pain in the neck. Jumping around different classes made me dizzy. So I said to myself "abstraction sucks, I will minimize abstraction when I design stuff".

Then, it came to the time I had to design an application (relative small web service component) from ground up. Remembering all the pain, I had a pretty flat design of the component. Problem was, when requirements changed I had to made change to many different places (requirements were quite fluid, and I couldn't do anything about that). It was so bad, I basically throw away my initial design and re-design with abstraction, and things got better - I didn't have to make changes to many places when requirements changed anymore.

I delivered the application, sat around for few weeks then was told to start maintaining the application. I had been a while, I didn't remember everything so I struggled a little bit to understand my own code, and the abstraction was not helping.

I was put on many other different projects afterwards and had the chance to play around with the abstraction levels a little bit more. What I actually find is, and this is just my personal opinion, abstraction helps a lot in development but has negative impact when you didn't write the code and are trying to understand everything to the deepest level of an application; you will spend more time jumping around different classes, and trying to make the connections.

My feeling is that abstraction is so valuable during development time that the trouble we go through as maintainer when trying to understand the code is worth while. Software exist to solve business problems, business problems evolve over time; hence, software has to evolve over time. Without abstraction, evolving the software is very hard. One can design abstraction in a way that the maintainer can navigate around the code base easily once they see the pattern of the code structure, so that only the initial learning curve is frustrating.

Title: What is the value in hiding the details through abstractions? Isn't there value in transparency?

Body:
Background

I am not a big fan of abstraction. I will admit that one can benefit from adaptability, portability and re-usability of interfaces etc. There is real benefit there, and I don't wish to question that, so let's ignore it.

There is the other major "benefit" of abstraction, which is to hide implementation logic and details from users of this abstraction. The argument is that you don't need to know the details, and that one should concentrate on their own logic at this point. Makes sense in theory.

However, whenever I've been maintaining large enterprise applications, I always need to know more details. It becomes a huge hassle digging deeper and deeper into the abstraction at every turn just to find out exactly what something does; i.e. having to do "open declaration" about 12 times before finding the stored procedure used.

This 'hide the details' mentality seems to just get in the way. I'm always wishing for more transparent interfaces and less abstraction. I can read high level source code and know what it does, but I'll never know how it does it, when how it does it, is what I really need to know.

What's going on here? Has every system I've ever worked on just been badly designed (from this perspective at least)?

My philosophy

When I develop software, I feel like I try to follow a philosophy I feel is closely related to the ArchLinux philosophy:

Arch Linux retains the inherent complexities of a GNU/Linux system, while keeping them well organized and transparent. Arch Linux developers and users believe that trying to hide the complexities of a system actually results in an even more complex system, and is therefore to be avoided.

And therefore, I never try to hide complexity of my software behind abstraction layers. I try to abuse abstraction, not become a slave to it.

Question at heart

Is there real value in hiding the details?

Aren't we sacrificing transparency?

Isn't this transparency valuable?


答:
At this point I can only add a reference to the Joel Article Getting Things Done When You're Only a Grunt.  The sections include:

Strategy 1 Just Do It

Strategy 2 Harness the Power of Viral Marketing

Strategy 3 Create a Pocket of Excellence

Strategy 4 Neutralize The Bozos

Strategy 5 Get Away From Interruptions

Strategy 6 Become Invaluable

I'd summarize the article as "Change has to start with you."


答:
With the caveat that each node has exactly one parent except for the root node, calling this a tree is fine.

With respect to building the tree, one way is to do the following:

keep some kind of associative lookup of existing nodes indexed by their unique ID (I don't know PHP, but I'm thinking some kind of dictionary or hash)

keep a similar lookup of orphan nodes, indexed by parent ID

when you create a node:

see if it's parent is in the existing set

if it is, attach the child to the parent

if not, insert the new node in the orphan set

then see if any orphans are waiting for it (nodes in the orphan set indexed with the new node's ID)

if there are, attach them and remove them from the orphan set

finally, add the new node to the existing set

at the end, anything still in the orphan set is either a problem, or should be attached to your root node.

Assuming, of course, you have some unique ID to identify parent/child relationships.

Oh, and I seem to have used the word set to mean some kind of associative container - note that it can't be unique or 3.2 will have problems with multiple orphans of the same node.

Title: Adding ordered nodes to tree in arbitrary order

Body:
I have a database of nodes.  Each node can have exactly one parent, but any number of children.  Some nodes may be stored with no parent, but at run time, I can create a default "root" node to be the parent of these.

First off, what is this data structure called?  I think it's just a "tree," but I want to make sure I'm using the correct terminology.

Another issue I'm running into is finding an efficient way to create the tree.  The nodes can be retrieved from the database in any order, so when I add a node to the tree, its parent may not be in the tree yet.  This means that when I add a node, I have to check whether any existing nodes have parents and then add the parent in the appropriate spot.

I've searched a lot online, but most talk about trees just refers to "binary trees," and even then I can't even find any good examples of constructing the tree in code -- it's usually working with an existing tree.

Are there any examples of efficient ways to build this tree (whatever it may be called)?  Language doesn't matter, but I'll be using php.


问:
Is a silverlight UserControl considered a view?
So far I have been implementing MVVM in my silverlight app pretty well, I just had one question. I have a few User Controls that I made and was wondering if they should be placed in the Views folder or in a seperate folder call UserControls. Is a user control considered a view?</p>

答:
A View can be a UserControl or a DataTemplate. A UserControl could be a View, however it is always a custom Control. There really is no relationship between the two.

So I would put the UserControls that are Views in your Views folder, while UserControls that are customized controls in your UserControl folders.

And personally, I wouldn't sort an MVVM application into Model, View, and ViewModel folders. It makes maintenance too obnoxious. Suppose you wanted to add a field to an item. You have to hunt down that item in all 3 folders to make the change. In larger applications, this is very annoying.

Instead I'd suggest grouping your objects based on their functionality. For example, I would place my CustomerView, CustomerViewModel, and CustomerModel all in a single folder called Customer.

In larger applications, I will separate the MVVM layers out into separate libraries, however the same concept still applies. The project that holds my data will store all Customer Models in a folder called Customer, my project holding my business logic will store all the Customer ViewModels in a folder called Customer, and my UI layer will store all Customer-related Views (UserControls and/or ResourceDictionaries w/ DataTemplates) in a single folder called Customer.


问:
GitHub: Are there external tools for managing issues list vs. project backlog
Recently I posted one of my the projects1 on GitHub and as I was exploring capabilities of the site, I noticed they have a rather decent issue tracking section.

I want to use that section as a) other people can report bugs if they'd like and b) other people can see which bugs I'm aware of. However, as others have noted, issues list cannot be prioritized in order to create a project backlog. For now my backlog has been a text file, but I'd like to be able to have it integrated so the same information isn't maintained in different places.

Having a fully ordered list, which is something we also practice at work, has been very useful as I can open one file, start with line 1 and fire off 2 or 3 items in one sitting without having to go back to a full issues/stories bucket. GitHub doesn't offer this.

What GitHub does offer is a very nice and clean API so issues can easily be exported into anything else. I've searched to see if there are other websites (like Trello) that integrate with GitHub issues, but did not find anything.

Does anyone know of such a product, service or offline tool? Those that use GitHub, what is your experience in managing backlog? I kinda hate the idea of manually managing two disconnected lists like some people seem to be doing with Wiki project pages.

1 - are shameless plugs allowed no this site? Searched but didn't find a definite answer. If it's bad practice, STOP and don't read further

As a developer I got sick and tired of navigating to same set of folders 30 times a day, so I wrote a little, auto-collapsible utility that gets stuck to the desktop and allows easy access to the folders you constantly use.

答:
This is a new space, so there aren't very many  tools in it.

Ryan Rauh's Huboard

Heroku's issue viewer


问:
How to Use Subversion Repository Inside Git Repository?
I'm developing a project in Git.  IT depends on another project, that's in a Subversion repository.  I'd like to be able to make changes to the Subversion project in the tree, and commit to/update from the Subversion repository from within the Git project.  Is that possible?</p>

答:
Git has an svn wrapper. Here is a quick run-down: Effectively Using Git With Subversion

Like many organizations using Rails, we have caught the git wave, and are in a state of transition between git and Subversion. Our open-source work is stored in git repositories, but our client work is still stored in Subversion repositories, and probably will be for some time. While git is amazing, Subversion still has its good qualities, and makes an excellent centralized repository, especially with its ecosystem of user-friendly tools.

The integration between git and Subversion (git-svn) is so well done that several of us have been using git as our interface to all our Subversion repositories. Doing this is fairly simple, but there are some interesting tricks, and so I thought I would share a day in the Viget life with git-svn...


问:
How do you respond to "Tell me a little bit about yourself." question in interviews?
I've been asked this in a few interviews. And it always catches me off guard.My professional and academic background are already in the resumé, which the interviewer has obviously looked at. What more to tell him/her? Should I start with my hobbies? I like gardening, or looking at NSFW pictures on reddit in my free time?

What and how do you answer to this specific question? Do you have a prepared answer for it? Am I wrong if I think this question is a bit silly?

UPDATE There have been a lot of great answers to this question. I'm in pickle which to choose as the 'correct' answer, because most of them are very insightful. I found a great writing on this subject matter. It's a bit crazy for my taste, but it's interesting:

How To Introduce Yourself… I Mean Practically

答:
I'll tell them about myself!

Details like: where am I from, when I studied, my likes/dislikes.


问:
How do you cope with the dynamic nature of high-level software development?
I consider myself a high level software developer. I enjoy reading a lot, and it's helped me over the course of my career. I think I am doing well.

Right now, I spend a lot of time learning new things. I don't suck when it comes to writing code right now, but I'm about to start a family, and I regularly see many seniors with 14-15 years of experience who—because they cut back on learning new things—now suck at programming. They were inspiring figures at some point of time, but they are not anymore.

You might argue that basics never change, but it does appear to make a difference when you are coding on Delphi for 10 years and suddenly everyone is using the .NET framework. It's true that an experienced developer will take less time when learning a new framework, but it still does demand time and effort.

How does a software developer manage the demands of the job while still being able to concentrate on things that necessarily take you out of the job, like starting a family?

答:
I have the same concerns in the back of my mind, but my recent thinking on this is to stop trying to predict your own ability to adapt and just adapt. I find that if I assume I can keep up, I usually just do. If I fret about getting outdated, that can make it a self fulfilling prophecy.

As you said, remain on your toes. And if you can't keep up, don't sweat it too much. Technology has a funny way of coming round full circle, and you might find yourself right back in the mainstream performing excellently.


问:
When learning Android, should I focus on the latest and greatest?
I'm a Java developer and I'm going to start working with Android to get familiar with mobile apps.  I've worked with Ajax toolkits, but haven't done any mobile development.

I've seen a huge change in development on certain toolkits where the learning curve really jumps up, as in GWT 1.5 versus 2.4.  I'm just wanting to jump in and get the basics (along with best practices) down for now.  I don't know if Android 2 versus version 4 would do that, but version 4 might just throw in extra features that I might not need to know about for now and take away from my main focus.

Is it better to go with the latest version of Android or, to make sure the fundamentals are covered, take an older version that would be easier to get in and start developing with?

答:
During your learning you should skip anything Android < 2.1 specific. There aren't too many devices on the market running those old versions, you can skip even 2.1.

First of all I would suggest to learn the developer guide: http://developer.android.com/guide/index.html
After you read those docs you should start the training section:
http://developer.android.com/training/index.html


答:
There's a chart that shows the share of every Android version, use this to identify which versions have a significant share, and which don't.

Going with just the latest version isn't a good idea most of the time.

Title: When learning Android, should I focus on the latest and greatest?

Body:
I'm a Java developer and I'm going to start working with Android to get familiar with mobile apps.  I've worked with Ajax toolkits, but haven't done any mobile development.

I've seen a huge change in development on certain toolkits where the learning curve really jumps up, as in GWT 1.5 versus 2.4.  I'm just wanting to jump in and get the basics (along with best practices) down for now.  I don't know if Android 2 versus version 4 would do that, but version 4 might just throw in extra features that I might not need to know about for now and take away from my main focus.

Is it better to go with the latest version of Android or, to make sure the fundamentals are covered, take an older version that would be easier to get in and start developing with?


答:
No one can keep up with everything.  You have probably been pretty busy keeping up with  Microsoft offering.  Have you looked at Ruby on RAILS and Python and NoSQL databases and Hadoop and mobile app creation and CSS and HTML5 and jQuery and ExtJS and ... ?

I've been in software quite a while.  I try to keep up with really new technology, like the new ideas for massively parallel databases, and ignore the ugly (e.g. MFC, WinForms, SOAP, XML, EJBs) and the trivial as much as possible.  Mostly we just see great old ideas repackaged and finally adopted.  Functional programming?  I was using INTERLISP in 1977.  Mobile phone apps? It's the same event-driven UI and 2D graphics we've been doing for at least 30 years.  Sure, there's an art to designing a usable app for a small touch screen, but the programming is not new at all.

Title: How do you cope with the dynamic nature of high-level software development?

Body:
I consider myself a high level software developer. I enjoy reading a lot, and it's helped me over the course of my career. I think I am doing well.

Right now, I spend a lot of time learning new things. I don't suck when it comes to writing code right now, but I'm about to start a family, and I regularly see many seniors with 14-15 years of experience who—because they cut back on learning new things—now suck at programming. They were inspiring figures at some point of time, but they are not anymore.

You might argue that basics never change, but it does appear to make a difference when you are coding on Delphi for 10 years and suddenly everyone is using the .NET framework. It's true that an experienced developer will take less time when learning a new framework, but it still does demand time and effort.

How does a software developer manage the demands of the job while still being able to concentrate on things that necessarily take you out of the job, like starting a family?


答:
I can't be the only one to think of the Xzibit nested items meme, right?  Anyway...

One of the remaining cool things that Subversion does is called "externals."  It's a way to point at a specific branch or directory in another svn repository.  You can even pin it down to a specific version of a specific directory.  Externals are really darn nifty, and would solve this problem in an instant, as changes made in an externals directory are automatically pushed back to the source when doing a commit.

Externals is also something missing in git.  Git has submodules, but they don't work in the same way, in that they're tied to a specific commit.  This effectively means that there's no native solution to the problem of having "nested" repositories that can be read and written to at the same time and remain perfectly in sync, no less nested repositories using different backends.

If you don't want to do the submodule revision pinning dance, there's another workaround.

Git has decent svn emulation in the git-svn tool.  You're probably already using it.  The SO question "How do I keep an svn:external up to date using git-svn?" offers us a useful option by abusing that tool.

The accepted answer was simply using git-svn to check out the Subversion repository outside of the tree controlled by git, simply using a symlink to point to it inside the tree.  There's a bit more manual work involved in this one, as you would need to remember to commit that specific repository every time you make a change in it.  However, it's simple, it's straight-forward, and it is known to work.

Another option entirely would be looking at Mercurial's subrepositories, which can host both git and svn.  I'm not sure if you really want to go three levels deep.

Title: How to Use Subversion Repository Inside Git Repository?

Body: I'm developing a project in Git.  IT depends on another project, that's in a Subversion repository.  I'd like to be able to make changes to the Subversion project in the tree, and commit to/update from the Subversion repository from within the Git project.  Is that possible?</p>


问:
Daily standups- yea or nay?
How valuable (or not) do you think daily stand-up meetings are?

If you're not familiar with it, this refers to a daily meeting that is part of Scrum adherents (and some other agile methodologies).  The idea is that you hold a daily meeting, timeboxed to 15 minutes, and in which everyone must stand (to encourage people to be to-the-point).

In the meeting, you go around the room and each say:
- What you did yesterday
- What you plan to do today
- Any blockers or impediments to your progress.

Do you think this practice has value?  Has anyone worked at a place that's done it, and what did you think?

答:
I think daily stand-ups are a great idea regardless of what methodology or area you're working in - provided you can keep them short 15min max. If you can't regularly keep to that then there are either too many people attending a single stand-up or the meeting isn't focussed enough.

Where we are the marketing team started copying us and now also have stand-ups - so it's not just for developers either!

Title: Daily standups- yea or nay?


问:
What can one do when "lead by example" doesn't work?
I have been working for a big company (8000+ employees) for almost 2 years now, and was hired just after I finished my study course.

Everyone here has to deal daily with legacy code which is often very badly designed and full of hacks. At first, I kept a low profile, trying not to criticize things too much. But the situation, as it stands, has become very difficult to live with and it seems no one is willing to improve/replace the tools we use.

To be more explicit we have:

An obsolete source control tool (Visual SourceSafe)

Plain old makefiles which only support full rebuild

.def files which must be maintained manually and separately for all existing architectures

monolithic headers files and projects with very few different files (but each has around 3000 lines of code, which sometimes takes care of very different tasks)

no use of the "new" languages facilities (well std::string is not that new but nobody except me uses it)

I decided, a few months ago to do something about it, by designing a new compilation environment. I could get incremental builds to work reliably, faster compilation times, better structured projects, automatic .def files generation. I even created a bridge from/to Git to/from Visual SourceSafe.

I showed my achievements to several collegues and our boss but it was like nobody cared. They were all like "Well... people are used to do it that way now. Why would we change things ?"

The changes I suggested were designed so that we could have a soft transition from the old system to the new one. Each improvement could be applied separately and safely.

I even tried to get some of my coworkers involved in the changes. But so far, no success.

Have you already faced a similar situation ? What can one do when "lead by example" doesn't work ?

答:
Do you work at an organization that believes doing things well, efficiency and innovation lead to success and profitability; or that the pursuit of revenue, and concentrating on maintaining sales are the tenants of success?

Companies that behave like you are describing are technologically entrenched.  In a competitive market they wouldn't be able to compete with a company who focused on individuals and innovation.

If you are the person you say you are, then work somewhere that honors and rewards your spirit.  Eventually after years of settling you will start compromising for the same philosophy that your superiors embrace.  Go work somewhere else (probably a smaller organization) that values hard work, inspiration, creativity, and progress.

If you don't take a risk and do this soon you will eventually settle and you will not be able to continue to feed your curiosity and creativity because it is philosophically opposed in your current peer group.

Excellence is an attitude and a world-view.

Just know that this experience gave you the insight to know what to avoid, keep your keen eye for complacency and protectionism so you can detect it early.

In your next interview ask questions like "What kind of innovations come from your employees", "What are some changes that came from individual creativity?", "What individual talents can I bring to this team?", "What drives your organizations success?",  "How is your organization continually embracing technological innovation?"...  The answers to questions like this are extremely telling.  Many organizations have no vision, or those that created the vision are gone, and the organization is ran by accountants.  If you are interviewing with the Director of Technology - ask him if he sees the organization as a technology company.


问:
Programming a chatterbot - understanding language
I hope this is an answerable question. Let me give it some context:

I am a psychology student and a programmer. I'm going to look into creating a artificial intelligence in the form of a chatterbot. I've been looking around the web, and read about projects such as Eliza which was a first simple psychotherapy program, that has now actually been written in javascript (so you can see how simple this was).

I want to create a chatterbot that can converse, and that will understand semantically and grammatically a sentence, for the purpose of reciprocal communication rather than simply outputting an answer. I'm interested in ways to learn about programming with "language". I know that this is a complex question, so the answer will probably be complex too.

What programming languages/frameworks should I look into when wanting to analyze the semantics. I know of the excellent Wolfram Alpha project that has an API. But I don't want to create an artificial intelligence that can answer any random question.

To paraphrase: What frameworks / programming languages are suited to work with deconstructing linguistic units and understanding language, for the purpose of conversing? Also do you know of any projects that implement these?

答: So far there are at least 50 years of research in natural language understanding.  You aren't going to solve it all by yourself, and choosing a programming language is about one-trillionth of the effort.  Look at the effort that went into building IBM's Watson.  They didn't even attempt to solve the general problem of language understanding.  They only had to understand clues well enough to formulate a probable answer.  Automatic translation systems are another good reference.  After hundreds of man-years of effort we have useful automatic translators, but nothing good.</p>


问:
Object-oriented design question
I am using a class through a dll to which I do not have direct control. So in effect, I am only a client of this class.

The class represents a form that can be printed, sent to clients and tracked in the system. I need to calculate two types of dates after which, if the form is received it is considered late.

Rather than simply calculate the late dates in the method where I am already handling the form, I want to extract the algorithm for calculating the late dates in a separate class as it is complicated and can be subject to change for administrative reasons.

Since I cannot modify the original class. I came up with these  possible solutions:

(For reference the code is in C# 4/.Net 4.)

A- Create a FormLateDateCalculator class that has methods to return a late date for a given form.

B- Create a FormLateDate class that takes a form in it's constructor and has a property for each type of late date.

C- Create two extension methods on the Form class that calculate the late dates.

While all three of these methods work (and I am sure there are others), I would like to know which is the best in regards to object-oriented design and why?

答:
All options are valid, I don't see anything particularly bad about any of them (well, maybe A unless it's a static class... but that logically resolves to C eventually anyway) but I see C as being the one I would choose. Here's why:

In code, you'll already have a form, and that's really all you should need to find out if it's late.

myForm.IsLate() or myForm.IsLateOn(DateTime) is short and perfectly clear.

Future developers will see this and not have to question what its purpose is. The static class can be named FormExtensions and there should be no confusion.

Title: Object-oriented design question


答:
I'd use approach A and hide it behind an interface, since it'll make the algorithm easily exchangeable where you use it.

I'd only use B when I have to store/cache multiple values that are created by a single algorithm. If the costs of a calculation are cheap and I only have to calculate two dates then I'd stick with A and calculate the dates whenever necessary. You can also use a combination of A and B where B is the container and contains the strategy interface (A) internally. But, as I said, I'd only create such a container if I really have to deal with many values (more than 4?)

I'd refrain from the extension methods as you can't have multiple implementations and as you can't interchange the algorithm easily during runtime, which may or may not be a requirement some day, who can predict the future after all?

Edit:

...separate class as it is complicated and can be subject to change
  for administrative reasons.

Use a strategy pattern. Will you need to have half the forms calculated with the old algorithm and the other half calculated with a newer algorithm or even worse? Will it be likely that you need two or more implementations of the algorithm simultaneously? Do you want to keep the algorithms or configure which one to use? If you have to answer one of these questions with "yes" then C is not an option anymore.

Option C is plain and simple and totally does the job when you are only ever going to need a single algorithm in place for every point in time.

Title: Object-oriented design question

Body:
I am using a class through a dll to which I do not have direct control. So in effect, I am only a client of this class.

The class represents a form that can be printed, sent to clients and tracked in the system. I need to calculate two types of dates after which, if the form is received it is considered late.

Rather than simply calculate the late dates in the method where I am already handling the form, I want to extract the algorithm for calculating the late dates in a separate class as it is complicated and can be subject to change for administrative reasons.

Since I cannot modify the original class. I came up with these  possible solutions:

(For reference the code is in C# 4/.Net 4.)

A- Create a FormLateDateCalculator class that has methods to return a late date for a given form.

B- Create a FormLateDate class that takes a form in it's constructor and has a property for each type of late date.

C- Create two extension methods on the Form class that calculate the late dates.

While all three of these methods work (and I am sure there are others), I would like to know which is the best in regards to object-oriented design and why?


答:
I would go with option A. It appears you have to calculate 2 different types of "due by" dates already, with things being subject to change, 1 of which could be adding a new means of determining lateness. Abstracting lateness calculations to another class lets you use the strategy pattern to figure out when the form is late.

For reference on the strategy pattern:

Wikipedia

DoFactory

Title: Object-oriented design question


答:
If you do not like the environment you are working in then you are doing a disservice to yourself.  You need to be surrounded by people who have similar interests and goals as you do professionally.  I know sometimes that is easier said then done, but the feeling of looking back several years and feeling as though you have wasted your time is worse than the fear of taking a risk.

As an alternative, if you want to develop in a system or an environment that uses specific technology and/or methodologies then I suggest you find a project outside of work that you can contribute to.  At the very least the variety of working on both systems will satisfy the need for something different while you find where you belong.

Seems to me you are fish out of water.  Go find your body of ocean and swim!