问:
Production or Custom Test Data for Unit Testing?
I've recently had a little disagreement with fellow developers. We're transforming various ontologies from the original source format (Pica+, RDF, etc) into our data format and have several converters dedicated to exactly this task. The argument came whether or not we should use the full ontology-data file, or create a subset specifically used for testing.

I argued the case for a subset:  a custom-created file of all use-cases required to confirm the converters are running correctly. They argued that a production file is always up-to-date and any change in the production file will break the tests. True, I said, but if a change of production files is needed, then invariable the requirements are changed, therefore this is not a fault of using test data. They considered this a very weak argument and summarily decided against the use of a custom-created test-file.

The question, as it boils down to, is whether or not to use the in-production file for testing our converters, or a subset of data. What are the pros- and cons? I'm very much in favor of using a test-file for converting, but I'm willing to assume that my premise is flawed. If I am correct, is there any way in which I can more eloquently and persuasively argue my case?

答:
I strongly suggest you to have both

artificial data in one or more small test files to check each requirement on its own (maybe for unit testing)

one or more production files of a certain size to check things you did not think of when designing your artificial data (this gives you an integration test)

To my experience, the chances are high that those two types of test files will catch different kinds of bugs. Furthermore, tests with small data are typically executed much quicker, this makes the chance much higher that someone actually uses that tests regularly (don't know if that's a factor for your product).

When your requirements change, you will have to update both kind of files, so this is neither an argument for the first nor for the second kind of test files.


问:
How to handle conflicts between developers in your team?
This is happening in every team.

For some reasons, conflicts arise in the team and they affect the overall motivation and productivity.

What is your recommended approach to solve that common problem?

Examples:

one part of the team wants to implement dependency injection, the other part think it's a waste of time.

some developers think the rest of the team is slowing down development (which explains why they are late on the schedule)

personal incompatibilities between one or more developers

one developer refuse to talk to another one (without apparent reason)

答:
It depends on the conflict obviously; they come in multiple flavors.

The religious argument ("Why do you keep using tabs instead of spaces?!?")

The point to make clear in this case is that, in principle, it doesn't matter which one is right, it's actually far more important that the entire team is using the same approach. Explain that to the minority opinion holder (and make sure to highlight that it's not necessarily the right decision, but also not important enough to draw blood over). The degenerate case of this is, for example, a developer refusing to use source control or submit to code-review. That's a management issue, and I honestly wouldn't know how to resolve it without letting the rogue developer go.

The personal argument ("I just don't like you")

There really isn't a way to mitigate this. Make it clear to both of them that bickering isn't acceptable, and that their personal grudges need to be checked at the door if they're going to be productive members of the same team (this works whether you're the manager or not; peers can be surprisingly influential if they're sure enough of themselves). If that doesn't work, either try to split them up on the org chart to reduce their professional/physical proximity, or get youself a desk well away from them.

The technical argument

The key difference between this and the other conflict types is that there is likely a correct answer. Typically it's to do with the code one or the other developer owns and how it should work (occasionally, it's a larger architectural argument). The key thing to grasp here is that even though there's a correct answer, you probably don't know it. The best thing you can do is mediate to make sure it's a clean argument, and hope that either side can be convinced. Again, you can do this whether they report to you or not, but if you're a peer, they might go to a manager to re-run the play even if you manage to bring them to a conclusion.

ContentLicense: CC BY-SA 3.0

ContentLicense: CC BY-SA 2.5


问:
Base64 decode and SH1 decryption of Sec-WebSocket-Accept value example from Websocket RFC
I am planning to implement the Websocket protocol and currently learning how handshake headers must be structured.

According to this link
http://datatracker.ietf.org/doc/rfc6455/?include_text=1

To prove that the handshake was received, the server has to take two

  pieces of information and combine them to form a response.  The first
  piece of information comes from the |Sec-WebSocket-Key| header field

  in the client handshake:

Sec-WebSocket-Key: dGhlIHNhbXBsZSBub25jZQ==

For this header field, the server has to take the value (as present
  in the header field, e.g., the base64-encoded [RFC4648] version minus
  any leading and trailing whitespace) and concatenate this with the

  Globally Unique Identifier (GUID, [RFC4122]) "258EAFA5-E914-47DA-

  95CA-C5AB0DC85B11" in string form, which is unlikely to be used by

  network endpoints that do not understand the WebSocket Protocol.  A

  SHA-1 hash (160 bits) [FIPS.180-3], base64-encoded (see Section 4 of

  [RFC4648]), of this concatenation is then returned in the server's

  handshake.

Concretely, if as in the example above, the |Sec-WebSocket-Key|
  header field had the value "dGhlIHNhbXBsZSBub25jZQ==", the server
  would concatenate the string "258EAFA5-E914-47DA-95CA-C5AB0DC85B11"
  to form the string "dGhlIHNhbXBsZSBub25jZQ==258EAFA5-E914-47DA-95CA-
  C5AB0DC85B11".  The server would then take the SHA-1 hash of this,
  giving the value 0xb3 0x7a 0x4f 0x2c 0xc0 0x62 0x4f 0x16 0x90 0xf6
  0x46 0x06 0xcf 0x38 0x59 0x45 0xb2 0xbe 0xc4 0xea.  This value is
  then base64-encoded (see Section 4 of [RFC4648]), to give the value
  "s3pPLMBiTxaQ9kYGzzhZRbK+xOo=".  This value would then be echoed in
  the |Sec-WebSocket-Accept| header field.

So when I actually decode "s3pPLMBiTxaQ9kYGzzhZRbK+xOo=" in base64 decoder on decoder, it gives me

@:e^qlk

Which I do not think it is going to decrypted into original value using SHA-1 properly.

So far, my understanding is

1) Server received Sec-WebSocket-Key value from client and combine that with GUID generated from the server

So it becomes like:
dGhlIHNhbXBsZSBub25jZQ==258EAFA5-E914-47DA-95CA-C5AB0DC85B11

2) then server applies SHA-1 and base64 encoding onto it

and the key becomes:
s3pPLMBiTxaQ9kYGzzhZRbK+xOo=

to send back to the clinet.

So in order to turn Websocket-accept value into the original "dGhlIHNhbXBsZSBub25jZQ==258EAFA5-E914-47DA-95CA-C5AB0DC85B11", I need to decode the above value using Base64 and decrypt it with sha-1 and I must receive the original value back. However, when I actually attempt it, it gives me the weird value I have mentioned above. Could you please correct me which part I am doing wrong? Thank you.

答:
You're testing the base64_decode incorrectly. It decodes to a series of bytes which are not characters which can be viewed easily. But testing in PHP shows that decoding it with the code

```<code>$array = unpack("H*", base64_decode("s3pPLMBiTxaQ9kYGzzhZRbK+xOo="));
var_dump(str_split($array[1], 2));
</code>```

gives the bytes.

```<code>  0 => string 'b3' (length=2)
  1 => string '7a' (length=2)
  2 => string '4f' (length=2)
  3 => string '2c' (length=2)
  4 => string 'c0' (length=2)
  5 => string '62' (length=2)
  6 => string '4f' (length=2)
  7 => string '16' (length=2)
  8 => string '90' (length=2)
  9 => string 'f6' (length=2)
  10 => string '46' (length=2)
  11 => string '06' (length=2)
  12 => string 'cf' (length=2)
  13 => string '38' (length=2)
  14 => string '59' (length=2)
  15 => string '45' (length=2)
  16 => string 'b2' (length=2)
  17 => string 'be' (length=2)
  18 => string 'c4' (length=2)
  19 => string 'ea' (length=2)
</code>```

As mentioned in chat, you don't need to 'decode' this anywhere, it's just that your server is meant to be generating the correct value from the source values to send back to the client.

Body:
You're testing the base64_decode incorrectly. It decodes to a series of bytes which are not characters which can be viewed easily. But testing in PHP shows that decoding it with the code

$array = unpack("H*", base64_decode("s3pPLMBiTxaQ9kYGzzhZRbK+xOo="));
var_dump(str_split($array[1], 2));

gives the bytes.

  0 => string 'b3' (length=2)
  1 => string '7a' (length=2)
  2 => string '4f' (length=2)
  3 => string '2c' (length=2)
  4 => string 'c0' (length=2)
  5 => string '62' (length=2)
  6 => string '4f' (length=2)
  7 => string '16' (length=2)
  8 => string '90' (length=2)
  9 => string 'f6' (length=2)
  10 => string '46' (length=2)
  11 => string '06' (length=2)
  12 => string 'cf' (length=2)
  13 => string '38' (length=2)
  14 => string '59' (length=2)
  15 => string '45' (length=2)
  16 => string 'b2' (length=2)
  17 => string 'be' (length=2)
  18 => string 'c4' (length=2)
  19 => string 'ea' (length=2)

As mentioned in chat, you don't need to 'decode' this anywhere, it's just that your server is meant to be generating the correct value from the source values to send back to the client.


问:
php templating with codeigniter
I am currently develop a website application in codeigniter, and I'd like to do something in PHP / CodeIgniter where I can make a common template for separate sections of the website.  I was thinking that I would keep the header / footer in a separate php files & include them separately.

The thing I'm not sure about is the content beneath the header and above the footer.  This website application will contain a lot of different pages, so I'm having a hard time figuring how what's the best way to do this.

答:
I generally prefer to create a "layout" file rather than having to include both a header and footer on every page. It's more flexible.

Here's a snippet from one of my projects:

```<code>ob_start();
include '../views/'.$templateFile;
$pageContent = ob_get_clean();
include '../views/layouts/'.$layoutFile;
</code>```

All you have to do is enable output buffering, include the template, then call ob_get_clean() to nab the contents of your template and put it into a variable. Once it's in a variable you can include your main layout file, which should echo $pageLayout somewhere inside.

e.g.,

```<code><html>
<head>
    <title>Your Site</title>
</head>
<body>
    <!-- header here -->
    <?= $pageContents ?>
    <!-- footer here -->
</body>
</html>
</code>```

That said, surely Code Igniter has some kind of templating built in, no? I'm not familiar with it. Edit: Apparently it does not. Kind of silly really; with caching, the performance cost of a nice templating engine is negligible.

Title: php templating with codeigniter

Body:
I generally prefer to create a "layout" file rather than having to include both a header and footer on every page. It's more flexible.

Here's a snippet from one of my projects:

ob_start();
include '../views/'.$templateFile;
$pageContent = ob_get_clean();
include '../views/layouts/'.$layoutFile;

All you have to do is enable output buffering, include the template, then call ob_get_clean() to nab the contents of your template and put it into a variable. Once it's in a variable you can include your main layout file, which should echo $pageLayout somewhere inside.

e.g.,

<html>
<head>
    <title>Your Site</title>
</head>
<body>
    <!-- header here -->
    <?= $pageContents ?>
    <!-- footer here -->
</body>
</html>

That said, surely Code Igniter has some kind of templating built in, no? I'm not familiar with it. Edit: Apparently it does not. Kind of silly really; with caching, the performance cost of a nice templating engine is negligible.


问:
Describe the best deployment environment you've worked with
The Joel Test includes the question:

Can you make a build in one step?

Which is important, but I'm wondering, how streamlined have some of the deployment processes been?

All software from shrink-wrap to web applies: what's the best deployment environment you've worked with, and what steps were involved?

答:
At one of my clients, we work in Rails and have everything set up so that the deploy pulls from git. We don't "build," though, since it's Rails.

So the deploy process is something like

```<code>git checkout review
git merge whatever-that-was
git push
cap review deploy:migrations
</code>```

The mix between Capistrano and GIT works out pretty well.

Of course, further scripting would be in order to skip some of these steps.

Body:
At one of my clients, we work in Rails and have everything set up so that the deploy pulls from git. We don't "build," though, since it's Rails.

So the deploy process is something like

git checkout review
git merge whatever-that-was
git push
cap review deploy:migrations

The mix between Capistrano and GIT works out pretty well.

Of course, further scripting would be in order to skip some of these steps.


问:
Why is C++ preferred over C for commercial applications?
I program in C mostly. However, it is pretty obvious that many more commercial applications are done in C++.

As far as I can tell, C++ is a very complex language, with seemingly convoluted syntax and too many constructs. C++ also encourages the abuse of Objects where structs and functions will do. In fact, the only significant advantage I see in C++ is the use of templated generic types (though, according to the developers of Go, generics are bad for programs).

Basically, my question is, did I miss something? Or is C++ more popular purely by merit of luck or marketing?

Edit: I'm sorry that I apparently asked a loaded question; in retrospect I can see that the way I worded it appears to be complete flamebait.

What I meant was, since C++ has so many different constructs and paradigms available to it, why hasn't it been replaced by languages that do less but are better at that specific thing? For instance, both Java and C# are much better suited for OOP than C++ is, while C is much simpler for system-level programming, and something like lisp is more suited for functional programming. Why is C++ used over one or more of these other languages?

答:
People want to use OOP. Also programmers want to learn as few new things as possible. Thus, when C++ first came out. It gained massive popularity thanks to backwards compatibility with C and because it implemented OOP, which was gaining massive popularity at the time. This popularity created so much momentum, that it maintains lots of it right until todays.

[opinion]

But todays, many better OOP languages exist and there is much less emphasis on backward C compatibility. I would reccommend looking into Java, C#, Python or Ruby for modern OOP language.

[/opinion]


问:
What is the name of λx.λf.fx (like reverse apply) in lambda calculus? Does the corresponding function have a standard name in programming?
What is the name of λx.λf.fx in lambda calculus?

Does the corresponding function have a standard name in functional programming languages, like Haskell?

In object oriented programming, is there a usual name for a method foo which takes a function as an argument, such that x.foo(f) returns f(x)?

答:
Using the standard combinators you can express this function as

```<code>C I
</code>```

where

```<code>C f x y = (f y) x
</code>```

In Haskell it would be

```<code>flip id
</code>```

Here id's type is specialized to (a -> b) -> a -> b and flip swaps a -> b and a.

You can also express it in the SKI calculus:

```<code>S (K (S I)) K
</code>```

Body:
Using the standard combinators you can express this function as

C I

where

C f x y = (f y) x

In Haskell it would be

flip id

Here id's type is specialized to (a -> b) -> a -> b and flip swaps a -> b and a.

You can also express it in the SKI calculus:

S (K (S I)) K


问:
What makes OOP "good"?
It's fairly obvious that OOP is viewed as a sort of silver bullet of programming today. In any computer science course, the merits of OOP are heralded.

I would like to know why people like OOP. To be honest, combining procedures, types, and data structures into a single conglomerate seems bad to me. I'd much rather view data as simply data. I like to be able to think that I will pass the right data through a function and get the right output, and not have to consider that the data is capable of operating on itself.

Also, I want to know if there are any good examples of robust programs written specifically with or without OOP, that have their source code available.

答:
Modularization: - Decompose problem into smaller subproblems that can be solved separately.

Abstraction (Understandability): -Terminology of the problem domain is reflected in the software solution. (Individual modules are understandable more easily by human readers.)

Encapsulation (Information Hiding): - Hide complexity from the user of a software of SDK. Protect low-level functionality.

Composability (Structured Design): -Interfaces allow to freely combine modules to produce new systems.

Hierarchy : -Incremental development from small and simple to more complex modules.

Continuity : -Changes and maintenance in only a few modules does not affect the architecture.

Title: What makes OOP "good"?


问:
how to map controllers , models, and views as a todo list
Before starting on a current project I was wondering if there is a terminology for what I am planning on doing? Basically what I want to do is map out every object in layers such as all the controllers and what they'll be called, the methods that will exist under the controllers and their purpose; Including, the models that the methods will be interacting with and the views that will be displayed based on certain actions. This way I've created a detailed to-do list and can catch any duplicates and make them as one call. I've heard of something called doctrine but I'm not sure if it will be what im looking for since i dont know how to use it but have heard of it having to do with documentation.</p>

答:
There are two sides to your question.

The process of writing down which classes there are and which methods they likely will have and how they will interact is called design.

The process of deciding in which order to make it all is called planning.

With both the design and planning, you can do as much or as little of it as you like, but I would strongly advise not to set the results of either in stone. As you work on the first portions of your code, you will invariably find smaller or larger gaps in either the design or the planning and you should be prepared to adapt both as you go along.


答:
To be honest, combining procedures, types, and data structures into a single conglomerate seems bad to me. I'd much rather view data as simply data. I like to be able to think that I will pass the right data through a function and get the right output, and not have to consider that the data is capable of operating on itself.

Here you ignore or seem not to understand one of the basic pillars of Object-Orientation and that is encapsulation. The point of OOP is that there is no data structure and there are no algorithms when you use the "conglomerate"; there are data and algorithms only when you build it, and only you - the creator of the class - should know or care what algorithms or what data structures are used. This, combined with the other 2 (polymorphism and inheritance - PIE) provide a great reuse mechanism and a great abstraction.

The object itself provides a great abstraction; it exposes (or ideally should expose) only behavior, which means that it can easily be changed with another object with similar behavior or it can be reused in another place which requires similar behavior. This leads to what is probably the most important thing about OOP - modularization. Basically your program becomes a bunch of loosely coupled modules that only communicate with each other via message exchange, which is a great improvement over the old way of programming where you have data and separately algorithms operating on that (global) data.

This lead to the production of frameworks, which actually do most of the job leaving the programmer only with the job of customizing with business logic rules and providing hooks into it. This greatly reduces programming time and makes feasible the creation of larger and larger systems.

From another point of view, object oriented programming greatly eases the modeling part as objects can be modeled more naturally into programming constructs.

But OOP is no silver bullet; as Fred Brooks famously said: "there are no silver bullets". Much of the theory about ideal OOP is not applied correctly which yields bad programs.

Also, I want to know if there are any good examples of robust programs written specifically with or without OOP, that have their source code available.

The thing is that there are a large set of projects that are only feasible to be build in an object-oriented approach mainly because of inherent complexity.

Title: What makes OOP "good"?

Body:
It's fairly obvious that OOP is viewed as a sort of silver bullet of programming today. In any computer science course, the merits of OOP are heralded.

I would like to know why people like OOP. To be honest, combining procedures, types, and data structures into a single conglomerate seems bad to me. I'd much rather view data as simply data. I like to be able to think that I will pass the right data through a function and get the right output, and not have to consider that the data is capable of operating on itself.

Also, I want to know if there are any good examples of robust programs written specifically with or without OOP, that have their source code available.


问:
How to create different paths for users to take through the pages in my site?
I have a website where users are directed to go through a sequence of pages to perform a sequence of work tasks (transcribe a paragraph, answer a survey, interact with another user, etc). For short, let's call these tasks A, B, C, etc. I'm using Django, and each task is currently implemented as a view function (or method), e.g. def A(request). Currently, each view function has the next step hardcoded in an HTTP redirect, e.g. HttpResponseRedirect(reverse(B)).

My challenge is that I will soon have a requirement to create various permutations of the sequence of tasks. Sometimes I will want users to do A, B, C; for others, B, C, D; for others, A, B, D, F. How can I architect this so that I can define these permutations elegantly and concisely in my code? Intuitively, I feel like I need to genericize the HTTP redirect calls with a variable, like: HttpResponseRedirect(reverse(next_view_function)), but I struggle to figure out where next_view_function should be defined, and how the definition of the sequence (e.g. A, B, D) should be persisted across requests.

Can anyone lead me down the right path with a suggestion or idea? I'm happy to provide more details.

Edit in response to Bart's questions:

The order of tasks is predetermined. Once we have defined it, we send the users a URL that takes them to the first page. They should then be routed through the tasks. One group of users might get a URL that takes them through steps A,B,C, while another group of users gets a URL that takes them through steps A,B,D. We decide in advance which users should get which URL.

Since the order is predetermined, the next step does not depend on the results of the current task. The only requirement is for them to complete the task (we of course validate the POST data they submit as a precondition to the HTTP redirect).

Edit 2, my solution so far:

A central concept in my code architecture is that of a "Treatment" (defined in my models.py). A Treatment is a specification of the experience a user has when they use my site, such as what UI is presented to them. I split my users into groups and assign each group to a different treatment by emailing them a URL that contains the PK of their treatment.

(There are also different subclasses of Treatment, since some Treatments are totally different from others. SoccerTreatment and HockeyTreatment have little in common, so it makes sense to subclass them.)

So, the class definition for a Treatment seems like the sensible place to store the sequence of views as a Python list, as follows:

```<code># in soccer/models.py
class SoccerTreatment(BaseTreatment):

    world_cup = models.BooleanField()
    ....

    def views(self, request):
        seq = [soccer.views.ViewClassA]
        if self.world_cup:
            seq.append(soccer.views.ViewClassWorldCup)

        return seq

# in shared/models.py
class BaseTreatment(models.Model):
    def next_view(self, request):
        seq = self.views() # views() method implemented by descendant classes
        if request.session.get('current_view_index'):
            request.session['current_view_index'] += 1
        else:
            request.session['current_view_index'] = 0
        # [handle boundary cases, code snipped...]
        # ...
        return seq[request.session['current_view_index']]

    # ...

# in views.py, at the end of a view function
# ...
HttpResponseRedirect(reverse(user.treatment.next_view()))
</code>```

However, the design above wouldn't work, since then models.py would have to import views.py, creating a circular import. So the list elements would have to be strings (either URLs, or a the name of the view class as a string), which could be brittle since renaming my classes or URLs won't automatically rename these strings.

Maybe I am being too picky, but I wonder if there is a better design.

答:
There are a few questions that will affect the design here:

Do you already have information that will determine the set/order of tasks, or will the order effectively be random? In the latter case, you could generate the task list when you create a new session and pass it along in the session data, along with an indicator where in the list the user is.

If you already have information on the set/order of tasks, in how far does this information consist of the answers/result of the current task? If there is a strong influence of the current task in selecting the next, you might be better off with a next_view_function per task. Otherwise, you might have one is a base class that all task controllers inherit from.

Update

In response to the update: You can either encode the sequence in the URL you give out (base64 encoded if you don't want it to be too obvious), or you can store the information in the session, like with the random order, except that the initial URL drives the sequence generation, instead it being random.


问:
when to mock in unit testing
I am trying to write unit tests in javascript for an application made in nodejs. What I want to know is -

Say there is a class Vehicles which is dependent on another class Roads.

Should I mock the Roads class and send it as a parameter to Vehicles for unit testing?
OR Should I just create a new object and send it as a parameter to Vehicles?

If I change the Roads class I will have to change the mocking every where?

Should I use a factory to create mocked objects?

答:
You should mock the Roads class if

It is expensive or difficult to create, or

Its operations are expensive, or

You need precise control over what the operations return and when they generate an error.

With expensive, I mean that it is generally consuming a lot of time (for example, communication across a network).

If you change the interface of the Roads class, then you need to update all the mocks and clients of it, but that should not be a consideration for whether or not to use a mock. If you just change the implementation without affecting how it responds to the 'outside world', then there is no need to change anything in that 'outside world'.

A factory for mock object should only be used if the class-under-test needs a factory to get (some of) the objects it needs from. Otherwise, it is just an additional complication for no gain.

Title: when to mock in unit testing


答:
Technically, you need to mock everything that is accessed from your unit, otherwise you're testing your unit of code and the code that it references. Now, obviously this can be impractical in the real world, so we tend to mock only the bigger aspects of the code, eg if your roads class called a DB to get some data, we'd mock the entire interface to the DB.

Its up to you how much effort you put in to make your code mockable, sometimes it can be a real pain altering your code so it uses interfaces (subject to language that requires this, eg .net, YMMV with javascript), but also it can be good practice to do this. The trick is knowing how far down that road to travel - too much and you have unmaintainable code that's so decoupled you can take days to trace what its supposed to do.

You don't need a factory, instead use a mocking framework that will automatically replace calls to your mocked object with its own that returns a fixed result, eg from Sinon.js

Title: when to mock in unit testing

Body:
I am trying to write unit tests in javascript for an application made in nodejs. What I want to know is -

Say there is a class Vehicles which is dependent on another class Roads.

Should I mock the Roads class and send it as a parameter to Vehicles for unit testing?
OR Should I just create a new object and send it as a parameter to Vehicles?

If I change the Roads class I will have to change the mocking every where?

Should I use a factory to create mocked objects?


问:
Keeping agile with zero-bug/defect policy
In our project we work in a zero-bug (a.k.a zero-defect) methodology. The basic idea is that bugs are always higher in priority than features. If you're working on a story and it has a bug it must be resolved in order for the story to get accepted. If a bug is found during the sprint for an older story we need to put it next on our backlog and resolve it - top priority.

The reason I'm saying resolve is that we not always fix the bug. Sometime we just declare it "won't fix" as it's not that important. All-in-all it sounds great. We're shipping high-quality products and don't carry "a hump" in the form of a huge bug backlog.

But i'm not sure this approach is correct. I do tend to agree that we always need to fix serious bugs ASAP and we need to throw-away non-interesting bugs. But what about bugs that are important but not as important as new features? I tend to think they should be filed in the backlog with a suitable priority.

I'll give an example in order for it to be clearer - in my project we work with a UI written in flex. We have a wizard screen that opens at the same size for every screen resolution. It turns out that when we extend the wizard window, one of the pages does not look good (there is a vertical scroll bar that does not disappear although the wizard can now present everything and does not require the scrollbar). I think this bug is ugly. I'm sure it MUST be fixed. But we're on a tight schedule and we have a lot of features that we're afraid won't make the cut and enter the release. I feel that we can live with such bug. It does need to be fixed but on lower priority than other features (so, in case we won't be able to complete it, at least we didn't leave out more important features). But, we work in a 0-bug policy and it must be fixed now (even though we spent more than a day trying to resolve it and we'll need at lease another one).

I would love to hear opinions about how to manage with bugs that I don't want to mark as "won't fix" but also are not of highest importance.

答:
Fixing bugs before writing new code is actually one of the twelve points of Joel test. Joel also explains why this is a must-have:

In general, the longer you wait before fixing a bug, the costlier (in time and money) it is to fix.

You have a choice:

Either you implement a highly requested feature and delay fixing a bug, which will inevitably increase the cost of fixing it,

Or you fix the bug right now, given that customers will be disappointed that you're so slow at delivering the feature they need so much.

If the bug is not very important, while the feature is, management will be inclined to ask to implement the feature first, then fix the bug. Business-wise, this is a perfectly valid choice, as far as the management clearly understands the consequences, i.e. that it would be more difficult to fix the bug later than now.

Sticking to "no new features until all bugs are fixed" may not be the best business choice. You already mentioned its limitations, so there is no need to explain it.

This being said, the risk of letting very important features be implemented before fixing minor bugs has a risk: where to put the limits? Is a feature requested by 1 000 customers is more important than a bug encountered by 100 customers? How to evaluate whether a given feature should be done before fixing a given bug?

Without strict rules and if management doesn't understand the development process very well, you may see yourself in a few years with a backlog full of bugs which were considered not important enough in order to be fixed before just another fancy feature.


答:
Basically, my question is, did I miss something?

I believe you did, but it has less to do with programming languages and more to do with the human tendency to denigrate the unfamiliar.  We do that.  It's natural.  Rising above it takes a willingness to endure the cognitive dissonance that comes with the comparisons to the familiar when learning something new.

You're doing two things you shouldn't:

First, you're looking at one language through the lens of another.  One of the things you'll start to understand as your horizons become broader is that programming languages are just toolboxes with variations on the same set of familiar tools.  The variations exist to solve specific problems.  Some toolboxes contain basic tools that force you to do a lot of things yourself; others give you things to make certain complex tasks easier.  My wife, who makes jewelry, has a dozen pairs of pliers that have very unusual jaws designed to solve specific problems.  To me they're just funny-looking because her problems aren't mine.

Second, you're looking at every tool that's not already in your toolbox as something ripe for abuse because it doesn't fit your concept of "how it is."  I have news for you: anyone with a lot of experience in a language can find a way to abuse any of its constructs.  C -- and don't get me wrong here, because I've written a ton of it -- is especially rife with opportunities for abuse.  Writing C is like owning a chainsaw: it's a great tool for removing unwanted limbs, but the line between use and abuse lies in whether those limbs are attached to your trees or your neighbors.  Constructs that enforce better behavior are the equivalent of adding blade guards and chain brakes to chain saws:  they were put there by the more-disciplined to keep them from having to clean up the messy results of the less-disciplined abusing their tools and hurting themselves or others.  A little light bulb will go on above your head the first time you realize you can do a complete reimplementation of a class without having to wonder if any other code is getting away with directly writing structure fields instead of calling the setter function you so thoughtfully provided.

Or is C++ more popular purely by merit of luck or marketing?

None of the above.  C++ is in wide use for the same reason as any other popular language:  people have found it a useful tool for getting things done.

Title: Why is C++ preferred over C for commercial applications?

Body:
I program in C mostly. However, it is pretty obvious that many more commercial applications are done in C++.

As far as I can tell, C++ is a very complex language, with seemingly convoluted syntax and too many constructs. C++ also encourages the abuse of Objects where structs and functions will do. In fact, the only significant advantage I see in C++ is the use of templated generic types (though, according to the developers of Go, generics are bad for programs).

Basically, my question is, did I miss something? Or is C++ more popular purely by merit of luck or marketing?

Edit: I'm sorry that I apparently asked a loaded question; in retrospect I can see that the way I worded it appears to be complete flamebait.

What I meant was, since C++ has so many different constructs and paradigms available to it, why hasn't it been replaced by languages that do less but are better at that specific thing? For instance, both Java and C# are much better suited for OOP than C++ is, while C is much simpler for system-level programming, and something like lisp is more suited for functional programming. Why is C++ used over one or more of these other languages?


问:
What to do when you are faced with programming task that you have never done?
I started my career as a .NET developer 3 months ago and after a long training plan on diverse technologies, patterns and concepts the developers who were supervising me have decided that I am ready to join one of the many projects the company handles.

I am very excited to finally be able to start coding. The team I have joined is rather small for now because were starting with a new project, which is great because I get to be involved in the entire life cycle of the project. It is a web based SPA project with a backed that uses ASP.NET MVC/ASP.NET Web API and in front-end the Durandal framework and related libraries.

My problem is that after having a meeting with my colleagues and establishing the tasks and estimations for the next month I find myself in a position that I do not know if I am capable of taking on any of the tasks.

I have never done any of the created tasks and I do not know how should I proceed.

For example one of tasks created is creating a generic error handling mechanism for the entire application.

How does one usually proceed when faced with tasks that he has never done?

答:
I think you're suffering more from anxiety than a skill deficit. At some point, wasn't everything new? Have you ever been given a task and not been able to solve it to some extent? You're paid to figure things out.

Utilize Your Team - If you're on a good team, you should be able to ask for help. There are things you'll know that even the most senior won't know. Asking for help isn't a sign of weakness (no more than running to some question site.).

Search -  A web search on generic error handling came up with nothing? You may not find an entire solution. You're going to have to work on it and make it fit in your app anyway.

Prototype - Change your perspective on the task from production to prototype. Just get something to work and build from there. When you get it to the point you can use it, then start thinking of it as production. Now you won't see the task as something you don't even know where to start.

Get Over It - Only doing things you know how to do will get boring. It also leads you into a trap of just brute forcing some solutions by repeating the same things over and over (If you like repeating things, go work on an assembly line.). Be prepared to make mistakes. Those that tell you they know everything, never ask for help or do searches, is just lying.

It's the old joke about doctors still "practicing" medicine; they don't have all the answers either.


问:
What is the difference between implementation and realization in Mythical Man Month?
In Fred Brook's Mythical Man Month chapter 4 (Aristocracy, Democracy, and System Design) page 49, he says:

As Blaauw points out, the total creative effort involves three distinct phase: architecture, implementation, and realization ...

implementer has plenty to do ... designing module boundaries, table structures, pass or phase breakdowns, algorithms, and all kinds of tools

...Meanwhile, on the realization level there is much to be done also. Programming has a technology, too. If the machine is a new one, much work must be done on subroutine convention, supervisory techniques, searching and sorting algorithm.

What is the difference between implementation and realization?

To me, an architecture is more related to specification descriptions or diagrams, whereas implementation is more to programming/coding, and it seems like the same as realization.

答:
The "new machine" part is key here.  He's talking about what most people refer to nowadays as "low level programming."  It's making a relatively machine-agnostic implementation work on a real machine.  That includes things like standard libraries, drivers, compilers, linkers, kernels, filesystems, etc.

You could also consider system administration tasks as part of realization.  You need physical hardware and a place to put it, cooling, user accounts, backup plans, redundancy, storage, network access, databases, etc.

In other words, you could have the greatest implementation in the world, but it does you no good unless it can be run on real hardware.


答:
As you rightfully indicate, a zero-bug policy has the risk that non-critical issues get ignored or shoved under the rug, because now is not the best time to solve them.

What you could do is, when a new issue gets reported, make a three-way decision:

It's a genuine bug and should be fixed asap: put on top of the backlog

It's a genuine bug, but is not critical to the functioning of the application: turn it into a regular story and let the product owner prioritize it.

It's not a bug, or it's a duplicate or it's not worth the effort to solve: reject with appropriate reason.

This way, the less important issues will not be entirely forgotten, but they are also not forcing all the new shiny features out of the next sprint. The 'turn it into a story' is just so that management can continue to claim you are following a zero-bug policy and the product owner should be able to balance the importance of the issue against the importance of the features on the backlog.

Note that, with this procedure, issues like the scrollbar you mentioned might still end up being unsolved at the end of the project, but then it was because nobody thought it to be important enough (including the customers), not because there wasn't time when the issue was found.

Title: Keeping agile with zero-bug/defect policy

Body:
In our project we work in a zero-bug (a.k.a zero-defect) methodology. The basic idea is that bugs are always higher in priority than features. If you're working on a story and it has a bug it must be resolved in order for the story to get accepted. If a bug is found during the sprint for an older story we need to put it next on our backlog and resolve it - top priority.

The reason I'm saying resolve is that we not always fix the bug. Sometime we just declare it "won't fix" as it's not that important. All-in-all it sounds great. We're shipping high-quality products and don't carry "a hump" in the form of a huge bug backlog.

But i'm not sure this approach is correct. I do tend to agree that we always need to fix serious bugs ASAP and we need to throw-away non-interesting bugs. But what about bugs that are important but not as important as new features? I tend to think they should be filed in the backlog with a suitable priority.

I'll give an example in order for it to be clearer - in my project we work with a UI written in flex. We have a wizard screen that opens at the same size for every screen resolution. It turns out that when we extend the wizard window, one of the pages does not look good (there is a vertical scroll bar that does not disappear although the wizard can now present everything and does not require the scrollbar). I think this bug is ugly. I'm sure it MUST be fixed. But we're on a tight schedule and we have a lot of features that we're afraid won't make the cut and enter the release. I feel that we can live with such bug. It does need to be fixed but on lower priority than other features (so, in case we won't be able to complete it, at least we didn't leave out more important features). But, we work in a 0-bug policy and it must be fixed now (even though we spent more than a day trying to resolve it and we'll need at lease another one).

I would love to hear opinions about how to manage with bugs that I don't want to mark as "won't fix" but also are not of highest importance.


答:
Besides diving into particular low level details of your situation, you better make sure that you got the basic, fundamental stuff right.

In this regard, I believe it is very important to point out that the policy you mention, "bugs are always higher in priority than features", particularly the word always deviates from at least two of four principles stated in Agile Manifesto:

Individuals and interactions over processes and tools

Responding to change over following a plan

I do not insist that you should change policy, because I firmly believe that one should be agile about very application of agile principles.

But you should be at least aware when you deviate and understand whether and how deviation is justified. Simply put, you better make sure that what you call "agile", doesn't actually slide into senseless fake, so eloquently covered in Half-Arsed Agile Manifesto:

Individuals and interactions over processes and tools

  and we have mandatory processes and tools to control how those
  individuals (we prefer the term ‘resources’) interact

Working software over comprehensive documentation

  as long as that software is comprehensively documented

Customer collaboration over contract negotiation

  within the boundaries of strict contracts, of course, and subject to rigorous change control

Responding to change over following a plan

  provided a detailed plan is in place to respond to the change, and it is followed precisely

For the sake of comlpeteness, it's not only agile principles that zero-bug policy seem to deviate from.

In non-agile projects I participated, it has been generally considered er... unwise to spend programmers time on fixing bugs that are not important enough to justify delaying release of high priority features.

Because of that, management typically spent (maybe it would be more accurate to say invested) some efforts into deciding what bugs could wait to next release.

Do you by chance work on mission critical software? I ask because in this case, zero bug policy makes pretty good sense and is worth compromizing agile / non-agile / whatever principles. Though I have hard time trying to imagine agile process in this case.

You know, unless you work on mission critical software, I would recommend to more closely assess skills and thinking abilities of your management.

I mean, from what you describe, it rather looks that they are simply uncapapable to properly prioritize bugs and features. If this is the case, if they can't handle such a relatively routine task, what else are they not capable of? Providing competitive salary? career growth opportunities? working conditions?


问:
Java MVC extra classes
I have a simple MVC project. My current packages:

gui

controller

db

domain

I want to put extra classes which I will use, e.g. md5 hashing, email validator (methods which I will use in more than one class). Where do I put them? I will probably not use them in only one package, but in two or three (not in model for sure). Do I create an extra package, or do I put them in domain as they're "static" (unchangable)?

答:
What you are looking for is a "utility" package.  This may include classes with static utility methods used all over the application.  Common utility classes are String operations, Date/Time, etc.
Your validators could be a subclass of the utility package, but personally I would put them in the domain in a higher "common" directory.

Refer to this answer for more details: How should I organize my source tree?

Title: Java MVC extra classes


问:
Advice needed - CMS vs. framework
I am going to make a website for a client that wants to be able to alter the site about every week (changing pictures and textual information mostly). It is for a restaurant and so the client wants to alter the menu and images on an almost weekly basis. I've always made my websites and web apps from a framework or from scratch and have never worked with a CMS, but would a situation like this warrant the use of a CMS? What are some other options?

Edit: I would really like a CMS to be a last resort option, but if it is most likely the best option I will use it.

答:
A Content Management System is what your customer wants.  You're asking if you should use a pre-built one or roll a custom solution of your own.

If your customer is not going to be writing blog-posts, a CMS system like drupal is probably overkill and unneeded complexity.  So long as your website pulls the menu items from a central data store, it should work just fine.

You may save yourself a partial security headache if you avoid the CMS, and have the updates made via a seperate channel.  A CSV or XML file with a folder of images would not be inappropriate, especially if the customer is familiar with Office software.

Conversely, if your customer wants to update via the web, a known CMS with a good security record may be a worthwhile pickup.

Title: Advice needed - CMS vs. framework


答:
Writing tests to show the bug when running the test is a good start to fix the bugs. But when trying to fix the bugs that has the least-of-all priority then we should think twice before proceeding with it. I did not mean to skip fixing it. But we can use non-critical resources to fix those bugs. Say, in my team, we train the new resources with the least prioritized bugs in the bug-list. By this way, we get a chance to train the new resource as well as impart a tint of confidence in them that they have made a fix in their entry to the application. This will certainly make them volunteer for the next prioritized task.

Hope this helps :)


问:
Load Balancing for Listeners
How should we load balance listeners to a 3rd party service?

e.g. We need to read gtalk messages via XMPP Listener and build an application using the interactions of the user with a chatbot. In such a case, how would we ensure that we can have XMPP listeners on multiple servers and we load balance the messages between the listeners?

Thanks in advance.

答:
If you can't modify the 3rd party, then you have to do the load balancing on your side using a Message Queue.

One server will listen to incoming messages in XMPP, and put it inside a message queue. This message queue will have multiple workers, so it will be automatically load-balanced between the workers. Once the worker is done processing the message, it will post the result back to the server.

Using a non-blocking server like NodeJS, and a broker-less message queue like ZeroMQ would be the best, low-overhead and high-performance solution. You may want to read more on NodeJS (non-blocking IO and event-loops) and ZeroMQ (0MQ is a library, not a server, so you don't need a separate server for it)

Title: Load Balancing for Listeners


答:
I like you scheme, however, as you have identified, it needs just a minor tweak to make it work - As you have observed, the reality is often a new feature trumps a bug fix.....

My suggestion is to force the bug priority increase each sprint. Lets say you have a bug at level 5 (scale 1-high, 5=low). It starts out as 5, 4 sprints later, its a level 1 bug. However, the mind set needed for priority calculation is "Current priority - Number of Sprints", rather than "Increase the priority of outstanding bugs at end of each sprint" - this prevents the priority being "reset" to low to defer it further.

Level 1 bugs must be addressed in the next sprint......

Is simple to explain, easy to implement....

Now, extent that to feature requests, maybe a different rate. After a while, the request must be dealt with - either done or discarded, preventing a backlog of features that have no value......


答: if they can't act maturely sack them both and get a professional, maybe a contractor/someone freelance ? </p>

Title: How to handle conflicts between developers in your team?

Body:
This is happening in every team.

For some reasons, conflicts arise in the team and they affect the overall motivation and productivity.

What is your recommended approach to solve that common problem?

Examples:

one part of the team wants to implement dependency injection, the other part think it's a waste of time.

some developers think the rest of the team is slowing down development (which explains why they are late on the schedule)

personal incompatibilities between one or more developers

one developer refuse to talk to another one (without apparent reason)


问:
How to persist temporary data over multiple HTTP requests?
In our webapplication we have a list of questions that have to be answered by the user. These questions are served to the user one by one and will be saved once the last question has been answered.

The problem we faced was saving all the 'help'-data that goes with this: storing the index of the last question, returning whether or not you're at the last question, returning the answered questions for the overview, etc.

Initially we stored this data each into its own session. This worked, but it also meant we had about 5 different session variables for each type of question list and a bunch of casts. I've removed these session variables by creating a few extra fields in the viewmodel and storing the viewModel in its entirety inside a session. This made sure we had our temporary data persisted troughout requests (each question solved meant a new request), removed a great deal of sessions and made the code more readable.

Another example of usage: our local user object gets overwritten every request because it's being obtained from a repository/databasecontext that's re-created every request (ninject). This also meant that we couldn't just keep a temporary list in our user that holds the already answered questions their answers, since it'd be emptied every request. Using this approach we can save this list in the session object, write it to the local user at the start of the action method, perform the action (save a new answer) and afterwards obtain this list and write it to the viewmodel. It's a bit of a workaround, but it made sure we could keep this data.

I believed this to be a decent solution, but now one of the project members (it's a school project due tomorrow) expressed his doubt about this method and said it was a very dirty solution (no alternative provided though).

We're using ASP.NET MVC 4.

Have I approached this the right way? How should I have solved it differently?

答:
Go with the ASP.NET Session object - it was made exactly for "persisting temporary data over HTTP requests" and it sounds like it was working for you.

Your project mates should recognize that a "dirty" solution which is working is better than a "clean" solution which is not. Real-world software development is about iteration and shipping working software.

15 session variables is ok. If you're worried about performance - remember never to optimize prematurely. If you're worried about cleaner abstractions - remember you can store strongly-typed objects in Session.

My suggestion is to model the answers/progress i.e. as a class and store that in Session.

p.s. hope your presentation went well!


问:
Important Questions to ask Client at Briefing (Web Development)
I am just moving into freelancing (my primary sector will be web design / web development). I've got a few projects for friends as well as one or two 'professional' projects in the pipeline. I would like to know what are some of the most important things you need to hear from your client before you start the process of developing their website:

Some examples I can think of are:

Wishlist of website functionality (contact forms / specific pages etc)

Whether they have an existing Google Analytics account

Any other tracking stuff

Legacy code that needs to be integrated

Desired aesthetics of the website

SEO discussion

So yes, I'd really like to know what you think are the most important things to discuss and ascertain from a client before you begin development.

答:
DO'S

Start by asking the customer why they want an website?  If needed,
guide them through a discussion about using it to grow business in
terms of sales, leads, orders etc.

Ask as many questions you can about their business now like how
are you getting orders, what is the process, how can it be done
better.

Try to understand the business process on how to get more business

and how to make the whole process to be more easy and simple.

DONT'S

Do not talk about the technology, you will be tempted to discuss but
don't.

Do not say demeaning things, if they have used any other
solutions before.


问:
How common is it for a team to write everything in-house?
In a recent interview I asked the interviewers "how do you go about evaluating new technologies and libraries (such as SignalR) and bringing them in to use?". They said they don't, that instead they write everything themselves so they don't have to rely on anyone else.

The firm doesn't work for the government or defence contractors or on any safety-critical projects or anything like that. They were just your average, medium-size software development firm.

My question is: how common is it for teams to write everything themselves? Should I be concerned by teams that do?

Edit -- Most every response has said this is something to be concerned by. Would a second interview be an appropriate time to ask them to clarify/repeat their position on writing everything in house?

答:
Of course you should walk away. I haven't seen it mentioned here, but the biggest reason to pass over the job is because you won't gain much in transferable skills.

Imagine at your next interview when they ask what technologies you worked with and you can only mention bare bones C++.. That sounds like graduate level


问:
What is a lambda, and why would it be useful?
So far I heard about :

Lambda calculus

Lambda programming

Lambda expressions

Lambda functions

Which all seems to be related to functional programming...

Apparently it will be integrated into C++1x, so I might better understand it now:

http://en.wikipedia.org/wiki/C%2B%2B0x#Lambda_functions_and_expressions

Can somebody defines briefly what are lambdas things and give an where it can be useful ?

答:
A lambda function is another name for an anonymous function - essentially a function without a name.

Usually you use this in languages where you will only need to use the function once. For example instead of

```<code>def add(a, b)
  return a+b
</code>```

and then passing that function into another function like so

```<code>reduce(add, [5,3,2])
</code>```

With a lambda you would simply do

```<code>reduce(lambda x, y: a+b, [5,3,2])
</code>```

Body:
A lambda function is another name for an anonymous function - essentially a function without a name.

Usually you use this in languages where you will only need to use the function once. For example instead of

def add(a, b)
  return a+b

and then passing that function into another function like so

reduce(add, [5,3,2])

With a lambda you would simply do

reduce(lambda x, y: a+b, [5,3,2])


问:
How to handle conflicts between developers in your team?
This is happening in every team.

For some reasons, conflicts arise in the team and they affect the overall motivation and productivity.

What is your recommended approach to solve that common problem?

Examples:

one part of the team wants to implement dependency injection, the other part think it's a waste of time.

some developers think the rest of the team is slowing down development (which explains why they are late on the schedule)

personal incompatibilities between one or more developers

one developer refuse to talk to another one (without apparent reason)

答: I don't think I'd be able to stand the babysitting aspect of management.  I'd tell them to settle it with a duel to the death.</p>


问:
What are the prerequisites for learning Go
I am considering learning Go. As far as I know about it, it's a systems language geared toward parallel programming. (correct me if I'm wrong)

Should I have a very good understanding of C in order to be good Go programmer?

How much systems concepts (*nix OS concepts) I need to master before delving into Go

What other things I should know/learn before starting Go

答:
Go isn't specifically a "systems programming language", it's a general purpose programming language.

You don't need any prior knowledge of C to get started, it's not very close to C at all (even syntactically).

You don't need specific systems concepts (Unix or otherwise) either. A fair understanding of how to get things done on the command line and how to use a text editor are pretty much all you need - and since you can do the Tour of Go entirely from your favorite browser, even that's not required.

Go would be fine as a first programming language (except maybe that Go being a relatively young language, you might find a bit less documentation and tutorials around than for others, and the tools/ecosystem might have a few more rough edges).

All you need is time to go through tutorials and introductory material on golang.org and elsewhere, patience, and curiosity.


答:
Scope

To me, scope is perhaps the most important question for any project.  It drives costs, schedule, feature set, and often quality as well.  It has a big influence on staffing and on whether your team is able to do the project (if it is too small, you better throw it back, too big, stay out of its way or bring in a partner).  Your lifecycle model may determine how you cope with scope.  If possible understand and act with a preference for short iterative/incremental cycles to a long waterfall approach where possible.

Exit Strategy

Related to scope, you should have completion criteria that are objective and measurable and will trigger partial and final payments as the project progresses.  Some fair and constructive method of assuring the project succeeds for the parties involved.  Communication, negotiation, arbitration are best used early and often to insure common expectations and in some cases to help projects that end in divorce damage the client and your company as little as practical.  Clients have varied willingness to pay, so make sure that their satisfaction can be assured without making your company a forever partner with one that is stingy and hard to please.

Title: Important Questions to ask Client at Briefing (Web Development)

Body:
I am just moving into freelancing (my primary sector will be web design / web development). I've got a few projects for friends as well as one or two 'professional' projects in the pipeline. I would like to know what are some of the most important things you need to hear from your client before you start the process of developing their website:

Some examples I can think of are:

Wishlist of website functionality (contact forms / specific pages etc)

Whether they have an existing Google Analytics account

Any other tracking stuff

Legacy code that needs to be integrated

Desired aesthetics of the website

SEO discussion

So yes, I'd really like to know what you think are the most important things to discuss and ascertain from a client before you begin development.


问:
Power of HTML5?
HTML5 is becoming more and more popular everyday. Many great online applications are now being created and described as pure HTML5 apps. (Like Muro)

But I don't understand what is exactly so cool about HTML5?

As far as I understand, it just adds few features for graphics that make good alternative for jQuery or Flash.

But still, it is not a programming language and it can not be used in any way to create an application, right? Still, every of the advertised HTML5 applications have only interface drawn by HTML5 and CSS3, but the core and logic of any application is still written in something more advanced, like JavaScript (at least part that runs on the client side in the browser).

Or is there something else about HTML5 that I just didn't find?

答:
Apart from the fact that it works, the main advantage is that it is an open standard un-encumbered by licensing, restrictive copyrights, patents etc.

Proprietary technologies such as Adobe Flash do not sit well with the ethos of the Web, which from the very beginning has been based on open standards which any group or organisation is free to implement and use. Furthermore the W3C standards procedure is open and democratic so anyone with a vested interest can have some influence on the standard.

The downside is that the standards process is s l o w. This is especially true for animated graphics where numerous non-standard technologies became available before W3C even decided there should be a standard. Thus FLASH become a de-facto standard for showing video etc. although with its numerous versions, security holes and locked down licensing it really was not a very good standard.

Title: Power of HTML5?


问:
Run Time Type Identification using Composition
It is said that programmers should prefer composition over inheritance.
I was wondering if RTTI can be achieved as easily using composition.</p>

答:
It is possible to create an inspection mechanism that allows you to identify delegation. In general this is not desirable because it breaks encapsulation and thus limits your options to change the class under inspection without breaking client code. On the other hand, if you need that kind of information in a special case e.g. some application of the command or strategy pattern, it is easily possible to add your own reflection methods.
However, I cannot think of an example where I would not consider such an approach as a design flaw and I would encourage you to look for an alternative design in which the caller does not need to know about the inner workings of the called object.</p>


问:
Protect Database Design - SQL
Perhaps a bit of an odd question but I can't think of a way to achieve what I want.

I produce a product which ends up installed on-site at clients premises. It is a business critical and high availability application, and has to handle processes very quickly.

While obviously most of the work goes into the actual application (Windows Services) part of the reason why the product is so good is intelligent database design.

Until recently I usually provided the servers and I was the only person to have access to the database and SQL Server instance. However more recently customers have asked to run the application on their production server, usually VMWare, and use their SQL Farm for the database.

This is fine for the application, however I am worried about who will have access to the SQL server and if they would be able to have a poke around in my application's database.

Is there anything I can do to prevent access to it? Or is it a case of if they're hosting it there is nothing I can do?

Thanks

EDIT:

If I am hit by a bus, company folds etc. there is an escrow agreement which will give them the source code of everything they need.

As to why I am worried I have seen examples in the past of people making changes to data tables and reports, and no they did not have  the nous to do so. This meant that someone had to go in and fix everything, while of course we charge for this I was wondering if there was a way to avoid it all together, or at least minimise the risk.

答:
The major software players, Oracle, SAP, ACI, Sunguard etc. etc. all have best selling products which come with a relational data base. None of them make any effort to hide or obfuscate the database schema.

In addition many customers for mission critical apps will demand a copy of your source code, as insurance that they can keep the system running should you go bust or get taken over by Computer Associates.

So why risk alienating your (ex-)customers who are after all not interested in writing their own software or they would not be interested in buying yours.

It should be noted that the databases supplied by the above mentioned customers are very hard to decipher -- but this is because the level of abstraction required to make the product flexible leads to a lot of indirection in their database designs (i.e. rather than a cust_name column in a customer table they have a cust_name_location column which refers to column ref256 in ip_ref_table)

Title: Protect Database Design - SQL


问:
JSON vs Foreign Keys
I'm developing an enterprise website, and I have to define some sections like this:

I have many sections and each section have many (or one) sub-pages.

The number of sub-pages vary per section.

Each sub-page should not be longer than 2500 characters

Also, I have to use a relational database (MySQL).

I'm in doubt which would be the better in terms of design and/or performance:

To store a JSON array, with all sub-pages as object, as a single column of the Sections table;

To create a table Sub-pages which references it's parent section by a Foreign Key.

答:
I would go with 2.

create a table Sub-pages which references it's parent section by a
  Foreign Key

When you have to do such Sections Sub-pages like things then I would go with creating separate  tables so that it becomes more efficient in organizing the data.

There's one scenario that I know which I would like to tell you. If you store all the sub-pages as object in one column of a section table, it becomes more complicated in terms of maintaining.  When someone wants to edit the contents you have to read all those data and then make calculation with indexes and so on.. Honestly I would consider it as a bad design. And then performance wise it works but might take some time in reading itself. So better to stick with second one by using the best relational models with RDBMS. Hope this helps.

Title: JSON vs Foreign Keys


问:
How to ascertain from the users if performance tuning has had the desired effect
So you've made some code changes that should hopefully speed up some part of an application. But there is just one problem - you don't know how it will perform in live.

Different networks, different machines, different memory, different configuration, different times of day, different users, different server loads etc etc etc

So...

(a) Do you ask them if that bit of the application has got faster?

(b) Do you ask them to monitor that part of the application?

Or...

(c) Do you just ask them to see if they notice any difference in the application in general? After all, you can't be 100% sure you haven't affected something else.

Each of these approaches would seem to have problems (I know this as I've tried them all):

(a) You're asking a leading question. Before such a fix goes life, there is an emperor's new clothes scenario. The developer believes the code should be faster so there is some kind of crusade to get everyone believing it before it goes live. So...it goes live. Some people say it is faster, some slightly slower and others about the same. What then?

(b) Again: Some people say it is faster, some slightly slower and others about the same. What then?

(c) You're no longer asking a leading question, but you start getting hit with a whole torrent of issues that people have known about for months (maybe years) but you've now opened Pandora's box. How can you be sure which if these (if any) are new issues?

Or maybe I should be asking different questions entirely. Any thoughts?

EDIT:

No doubt there are processes leading up to this point that could potentially be improved. But the nub of the question is this:

The change is tested and has been put live. You have a myriad of stats to prove the changes should improve performance. Your boss has given the stats a once over but now wants to make sure the users are happy before signing off the release. What question(s) should you be asking the users?

答:
Your problem here is that you are involving users as testers, don't do this.

Your question is quite valid - how does an app perform once it gets to the "real world", with real world CPUs, user load, data volumes... but once you ask this question, you need to get some objective performance figures and users are never going to be much use for those.

So you need to emulate the user load, in a QA or performance test environment. Get a representation of the end-user environment, get some automated test tools that can hammer your system as if 10, or 10,000 users were using it, populate the data sets with masses of dummy data. Then you can run your tests and get some meaningful data. Then you can also re-run your tests with a new version of your system and see what differences there are.


问:
What should I do in AJAX or PHP?
Since I discovered the joys of AJAX, I tend to do all my requests to the server using AJAX. Is this a good idea?

According to you, what should I do in PHP and what should I do in AJAX?

I like to do my requests to the server with AJAX because I can use it as a kind of web service.

答:
These are two different type!
PHP is a server side and you can do anything with it.
continue to show on client side anything you want with ajax and post your data to PHP. like stackexchange.com</p>

Title: What should I do in AJAX or PHP?


问:
write my own or choose a framework for link sharing website
I'm a PHP programmer and I've done any projects based on PHP and MySQL without using any framework so far.

Now I'm going to create a big link sharing system (excel-able,modular,fast,theme based,secure etc.). But I have no experience to use any frameworks before. I need to know which is better to me.Choose a framework (easy to use and learn it fast) or still do my method?

答:
I would tell you to go with any of the frameworks. I personally feel good with codeigniter because I feel more comfortable with its level of documentations. There are several reasons why use frameworks. I would like list to few of them.

MVC (model view controller) patterns. This actually keeps your model(data), view(templates or theme) and controller ( handle page requests and bind everything together) separate.

Libraries and utilities. There are many things readily available to you. You should just use them. The documentations will probably help you a lot. So you don't have to reinvent the wheels.

Security. There are many things available to you in php so that you can just use them to control some certain attacks. But still there are chances that you may miss something. In frameworks many things are done for you automatically. For an instance consider SQL injections.

caching, benchmarks, profiling. These things may be readily available for you with frameworks. That's basically a performance related one.

For a team work it great suits.

These are the things which I found good about frameworks. frameworks helps us write cleaner code. It is always a good thing to work on frameworks. Using frameworks will provide maintainability. I would recommend you codeigniter. But cakePHP is also fine. Have a look at this link. There is a good comparison between those two frameworks. Hope this helps.


答: It is important that your model and your DB use the same paradigm, else you have too much "frictional loss". So if your data don't fit in the relational schema, you might consider to switch to a NoSQL DB (like Mongo DB).</p>

Title: JSON vs Foreign Keys

Body:
I'm developing an enterprise website, and I have to define some sections like this:

I have many sections and each section have many (or one) sub-pages.

The number of sub-pages vary per section.

Each sub-page should not be longer than 2500 characters

Also, I have to use a relational database (MySQL).

I'm in doubt which would be the better in terms of design and/or performance:

To store a JSON array, with all sub-pages as object, as a single column of the Sections table;

To create a table Sub-pages which references it's parent section by a Foreign Key.


答:
AJAX is used in cases where you can speed-up user actions by avoiding useless page refresh. In general:

Use AJAX when an action of the user affects a small part of the page and the action is done regularly.

Don't use it when an action of the user changes nearly the whole page or the action is done rarely.

Since you're complaining in your comment of the answer by DougM to be unable to find an example, here's an example which considers different scenarios of an application, indicating for each whether AJAX can be used and what criteria should be taken in account to make the choice.

Example:

Let's take a web page where users can view and add post-its (which would be useful in a context when they need to take short notes, like a phone number, in order to access them later from everywhere). For the sake of simplicity, we will not discuss registration/logon.

First, the user arrives. This is an ordinary request, since there is no page which can be used as a base for AJAX. So no AJAX here.

Then, the user fills an empty post-it and submits the new content. Here, AJAX can be useful: instead of forcing the user into the page reload, sending again all the menus and logo at the top and copyright notice and links at the bottom, etc. A more elegant way would be simply to shake the post-it to indicate that it's posted, or change its appearance in some way, and voila.

If the post-it is removed, AJAX can be useful again. Instead of refreshing the whole page, just remove the concerned post-it from the list. The situation is similar when the user removes the post-it, then clicks on "Undo removal" link which appears for a few seconds.

Now, the user wants to filter post-its (we assume every post-it is displayed on the page) in order to search for one. Here, you don't do requests at all (unless you want to keep a log of what was searched). You simply hide, through JavaScript, post-its which don't match, and keep showing the ones which are matching the filter.

Let's assume now that not every post-it is displayed on the page, i.e. there is a "Page 1 · 2 · 3 · … · 16" bar. When the user switches from page to page, you might use AJAX, or you may avoid using it. In fact, loading all the post-its on a page may take some time: nearly the same time as loading the whole page with top logo and menus and bottom copyright notice.

Finally, what about a user who removed a post-it few days ago, and now wants to recover it? No matter how much content is changed, you don't use AJAX here. In fact, the feature will be accessed by only a few users, and not very often. Implementing AJAX and adding complexity for a feature which is barely used isn't worth it.

Title: What should I do in AJAX or PHP?

Body:
Since I discovered the joys of AJAX, I tend to do all my requests to the server using AJAX. Is this a good idea?

According to you, what should I do in PHP and what should I do in AJAX?

I like to do my requests to the server with AJAX because I can use it as a kind of web service.


问:
Best way to structure a Git repository for Maven
I need some advice on how to structure our projects in Git. We use Java and Maven is our build tool. Maven kinda assumes all of your projects have a common ancestor eventually. Maven can also be a real drama queen when things aren't setup exactly the way the Apache foundation sets up their projects (anyone using the release plugin probably knows what I'm talking about).

We want a top level parent pom that controls plugin versions and build configuration (repo config, what artifacts to build, naming conventions, plugin versions, etc). Maven would want all of our IT projects to be in subfolders of that main project. This implies one massive Git repo for the organization.

This will make for a very noisy environment. If there are two teams working on unrelated projects, they will constantly have to pull in merges from the other team. Ideally I'd like to have one repo per project.

But that sort of clashes with the extremely hierarchal model of Maven, which demands sub-projects be sub-folders.

I need some advice on how people have reconciled these two models... thank you!

答:
Maven would want all of our IT projects to be in subfolders of that main project

No, Maven simply wants to be able to retrieve the artifacts that it needs. The best way to do this is with an artifact repository, such as Nexus or Artifactory. Each project can have its own Git repository.

We want a top level parent pom that controls plugin versions and build configuration (repo config, what artifacts to build, naming conventions, plugin versions, etc

There's your real problem. It makes sense to use a parent POM to enforce configuration, but there's no reason to combine configuration with build control. In fact, except for a stand-alone multi-module project, I'd say that it's an extremely bad idea, for just the reasons that you state (plus the fact that you'd have to build all of your projects, all of the time).


问:
How can I manage a central repository of documentation?
Our team works with a large number of different APIs and services, and we also have our own internal tooling and services we maintain as well.   Right now, we do not have a good centrally managed system to list which projects we used a certain API on, or to attach documentation for all of our utilities/apis.

I believe what I am looking for is some type of team wiki, but we weren't impressed with the search capability of the the solution we tried (Sharepoint).

Are wikis the right way to approach centralize documentation? What types of things should I be looking out for when creating a centralized documentation system?

答:
A wiki is a great approach to centralizing documentation in an organic way.

Of course, "organic" implies flexibility but also the possibility of making a mess. In a developer environment, with a few simple policies in place, it's a perfect place for each developer to contribute rather than having docs sprawled across storage devices or stuffed in a shared folder.

The types of things we were looking out for were:

Integration with existing user authentication

Flexible authorization so we could let clients in and partition dev teams

Compatibility with Office docs to accommodate PMs :(

We ended up using Confluence and love it. Hope that helps!


问:
Is it completely impossible to have total separation without leakage of any kind in a design?
For the past week I have been attempting to write a proof-of-concept project using dependency injection, a service layer, unit of work pattern + repository.

I am looking to design something that can easily be consumed by any type of application - be it a Windows desktop application, a CLI application, an ASP.NET MVC application, even an iOS application running Mono. Please, bear in mind that this is just for a proof-of-concept.

Until now, I have written

A Unit of Work + Unit of Work Factory for NHibernate and Entity Framework (2 OR/M frameworks for .NET)

(Generic) repository. There is one repository per OR/M implementation, taking it's respective Unit of Work Factory as a constructor parameter. It needs this to grab the current unit of work (since it's implementation contains stuff necessary for each OR/M framework to function)

This has accomplished:

I can swap out implementations of the repository and Unit of Work factory with NHibernate and Entity Framework, and it will just work. This is good, except I haven't implemented a real application yet, only unit-tests.

These are the problems/challenges I am facing:

<s>Each application type (Desktop, CLI, ASP.NET MVC, iOS, Android, whatever) do not define a unit of work the same way. A desktop application (AFAIK) should have a Unit of Work per screen - a Web application should have a Unit of Work per request, etc. I don't know how I would share a single unit of work with all the repositories/services (see below) that needs it.</s> - Michael is right.

I want all my logic to reside in a service layer. The service layer decides when a Unit of Work should commit. The idea is that whoever calls the service, knows what to pass to it, and knows what to expect as a result. If something goes wrong, the service logs it. If I had to do this on a per-application basis, DRY would be violated (right?).

It seems that if I had to implement this totally separated design, the amount of code I got to reuse would not be as much as the amount of code I'd have to write in order to implement it in each application type, which would, in the end, most likely leak my IoC container into the application.

Am I totally crazy for even attempting this?

EDIT: The actual problem I am facing, is providing my service layer and repositories with the same instance of a Unit of Work, no matter what application type is being used.

答:
Each application type (Desktop, CLI, ASP.NET MVC, iOS, Android, whatever) do not define a unit of work the same way. A desktop application (AFAIK) should have a Unit of Work per screen - a Web application should have a Unit of Work per request, etc. I don't know how I would share a single unit of work with all the repositories/services (see below) that needs it.

To me, this sounds like you are defining "a unit of work" around how it is presented to the user, rather than around what makes sense to perform as a single operation. Depending on how much state you want to keep and where, "a unit of work" isn't going to be "purchase an item" (taking an example for an ecommerce application just to have a concrete example) -- that's more like a scenario or use case -- but perhaps rather "add given quantity of given product to shopping cart", "get contents of shopping cart", "set delivery address", "set payment details" and "confirm order".

If you do it that way, you can easily expose the functionality (purchasing something) in ways that make sense in whatever UI you are working with. A web application might display the contents of a shopping cart on one page and ask for customer details on another, while a client GUI application might integrate it all into one physical view. Each client application will of course still require knowledge of how to perform the various operations, but they won't need intimate knowledge of the overall architecture any more than you need to know every implementation detail of Win32 to build Windows applications (oops, bad example ;)).


问:
Advice needed - CMS vs. framework
I am going to make a website for a client that wants to be able to alter the site about every week (changing pictures and textual information mostly). It is for a restaurant and so the client wants to alter the menu and images on an almost weekly basis. I've always made my websites and web apps from a framework or from scratch and have never worked with a CMS, but would a situation like this warrant the use of a CMS? What are some other options?

Edit: I would really like a CMS to be a last resort option, but if it is most likely the best option I will use it.

答:
I agree with @DougM.  It really sounds like your customer wants a CMS.  I can sympathize with your hesitation to install a CMS.  There is a lot to learn and to be responsible-for.  Plus, since you are a programmer, the tempation to extend it will be very strong.  Make sure you learn the CMS really well before you try to extend it (to avoid duplication).

The experience of installing and administrating a CMS will be really good for you and it will be great on your resume.  In contrast, passing-up on this opportunity to gain the experience, would be unfortunate.  As a programmer, you should feel honor-bound to learn new technologies, like this one.  Plus, diversity of knowledge is a big step towards being qualified as a system architect.

Title: Advice needed - CMS vs. framework


问:
What to do as a Dev when for years their team has lacked product innovation, not used project mgmt methodologies, and kept bad Software Dev practices?
I am interested in knowing how to deal with a current software development process that has not been changed for years and will eventually lead to product and team failure. Yes, probably the easier way to solve this is changing jobs, but with this economy is easier said than done. However, if you have specific examples and have seen or been multiple times in same situation and think that the best solution to address these issues, is to leave the company, then please support your answer. The point is, this question really has an answer especially if multiple experts on the subject end up indicating that the best route to go is : route A.

I know tons of developers have been or are in similar situations. This is one of the main reasons why companies go from being # 1 in their market to becoming last or even off the market. Hopefully the answers in this post will help other developers facing similar obstacles. In a small or large development team this usually happens:

Some developers seem not to care and decide to go with the flow and prefer to leave code with lots of code smell the way it is and development process as is,

Others get tired of no change and resign and move to another company,

Others seem to be afraid to talk and prefer to stay quiet,

At times very few developers or just one tries to speak up for improvement of product, and tells the team how important is to follow best coding practices and benefits of doing so for clients, users and team. These type of developers usually decide to stay with the team due to reasons such as company offers benefits that very few software companies offer, or the product has lots of potential, etc.

The product in our team is just a fraction of where the company gets its revenue from as it has an umbrella of products (this company is not a software/hardware company; therefore, no constant patent litigation, at least for now, which creates job instability). What I have learned so far during these years from other developers’ experiences and my experience is that to really know a development team, it takes time, not days, nor weeks, but a few months. During the interview process if the team wants to hire you, or needs you; they make everything sound great, and they might tell you what you want to hear. However, the reality is different when you start working in that team and begin digging inside the code and moving towards the complete SDLC process.  This is when as a developer, you start seeing the reality of the job you got into. This reality makes it difficult to want to move from one company to another because it is hard to know if the company you move to will be better or worse. Yes, you can read Glassdoor reviews etc.., but how many of those online reviews are real, and not from HR?

What would be the best way to tackle the issues outlined below considering that manager from the beginning has always resisted to change, and previous developers have been doing the same for years?

Lack of product Innovation for years: Product has lots of potential and brings good revenue to the company, but product looks like it was made 20 years ago. Some users have complained that product is not user friendly nor intuitive, and others have mentioned that are used to apps like Gmail and get frustrated when using the product because of not having similar features. The main issue here is that when you try as a developer to make changes to the product and start to move main elements of product around just a couple pixels away (to make it more user friendly, or intuitive), manager panics, and tells you to put it back where it was. If you try to add a feature that will benefit productivity for users, manager asks you to  remove it because of "users are used to doing the process the way it is etc.." I think you got the point of the resistance to change, improvement and innovation (manager is not open to change, even when you as a developer provide strong arguments of benefits). Company has a few competitors in the field (the products of few of them are way more competitive), but somehow the company has maintained the current clients for years.

Lack of project management coordination: As a result of this, some projects are delivered late, with bugs and some clients complain (clients report the bugs too), or budget is used too fast prior to delivering project etc.. I've provide them a few project coordination tips and the ideas are now being used regularly to track progress of projects and tasks to be done.

Bad software Development Practices: Code smell is seen on most if not all files, no documentation, code redundancy, front end tier and back end mixed on same file, outdated development tools, no a real testing environment nor test tools (just copy and paste files from dev environment to production, and then test manually that things look good and release) . Most of the development tools I use for development and testing where unknown by team, as team only uses 2 IDEs for code development and source control is only available for development environment. Other developers have tried to use latest frameworks to improve current issues, but manager does not like it because of "what if you leave, then who is going to maintain that code?, let’s leave it the way it is" Some of those developers already left and moved to another companies.

In summary, I am sure similar situations happen to many developers in other companies but due to different circumstances, a developer might prefer to stay in the team than going to another company for reasons like (convenience of job, work flexibility, company benefits, or just because a better opportunity has not arrived). There is not perfect company that I know of, but how would you as a developer behave and approach all these issues in order to keep things positive and ultimately promote change for the improvement of product and betterment of the software development process (whether you have many years of development experience or just a few)? I know this is post is long, but I preferred to give extra details to increase chances of getting more useful feedback.

Thanks a lot for your all your feedback and time

答:
The obvious short answer is to leave the company.  Others have already left, and your manager is an active obstruction to progress.  If you stay in that position you'll slowly decay (both in morale and skills).  Finding a new job isn't always easy, but in this case it is necessary.

Just in case you chose not to leave the company (the first line of your question kind of gave that away):

Does your manager have a boss?  If so, how does that boss view the product?  Can you (dare I even say it?) go over your manager's head and approach his boss?  Don't nag him with technical details, just express interest and enthusiasm in growing within the company.  Present tangible ideas for improvements that would measurably affect the bottom line.  You might get promoted out from under the obstacle.

Be warned though - while some squeaky wheels get greased, others get replaced.  You WILL cause your manager to strongly dislike you.  He will hear about this, and he will say unkind things about you to his boss.  Tread carefully, but remember - no risk, no reward.

The worst that can possibly happen is that you'll be looking for a new job, which you should be doing anyway.


问:
Documenting reports for end-users
I have an application that has about a dozen reports that provide totals and summaries of data in the database based on date ranges given as parameters. The application is near the end of user testing. The end-users are saying that the numbers in the totals don't match what they expect based on test data they have entered.

It seems like the developers and users interpret the data differently.

How can I document the reports in a way that the users will be able to see which records are being counted,summed etc to get the totals, without overwhelming them with technical details?

So far I have tried to write out the queries used in the reports in pseduo-code, but it seems too technical and I'm worried I'll just get the same 'The report doesn't produce the correct data.'...

答:
When there is a dispute between the users and the program about how the program should work. The solution isn't to fix the users. That goes double when you're presenting data to domain experts.

In this case if the devs and the users have different ideas about what data should be presented, then correct response is to make the data presented match the user's expectations, not painstakingly explain to them why it's wrong.

They're the ones who are going to be using the data, so they're the ones who know how the data should be interpreted.

I'd suggest that the correct response isn't to document the system, it's to fix the system to meet their requirements.

Title: Documenting reports for end-users