问:
Is a large increase in velocity realistic in a Scrum environment?
My manager has recently really been pushing to use velocity as a target and measure of productivity. We are currently working at an average velocity of 50 story points. My manager wants us to increase it by 40% to 70 story points (with no increase in team members). If we don't achieve this increase he wants us to deliver a full break down explaining why.

The whole idea of measuring team performance by velocity and using it as a target seems wrong to me, but I am finding it difficult to explain why. Any help? Why isn't this the right way to measure and incentivize productivity?

答:
Regarding my experience and going straight to the point.

First, you could inflate the estimation but it doesn't mean you're doing more.

Second (premise: without inflating, just focusing in team velocity),

Try to find the skills inside your team. Are they working on what they're best? Do you need an systems architect to make the difficult decisions regarding construction of the application and complex things? How the team is spending their efforts? They're spending time researching solutions for their problems, refactoring, making business decisions or what?

Are they comfortable, focused and estimulated? What's going next for them?

This is not "i'm pushed on the limits"... it is more like a question for the whole team "Are we on the limits?" and "How can we push the limits?"...

I have leading high performance teams (for first construction and/or migrations)... the motivation of the team is the key of success... and planning how would the base of the application shall be is essential. Sometimes I or a teamate get the role of Systems Architect and decide how and where the "thing" should go.

Sometimes when I see that my teamates are losing efficiency, I try to break and invite them to get out for a drink beer, or something they like. This solves any conflicts and on the next day they're focused again.

SELLING...

If explain the reasons you can't increase the velocity is hard, use the ROI.

Scrum focus on what's most important for the client. Theoretically the most profitable tasks.

If your problems is regarding selling the development effort, what do you think sell whats the ROI of development effort instead directly convert story points to the "price". If you can proof that your team works with a high ROI, who's going to question you? Also, every team has its limits if the team has found its "confort size", try month-by-month a slightly increase, if they couldn't finish all tasks this is (probably) the limit.

Show the history of the tasks, the profit revenue (if available), the story point you have used, and show that PRODUCTIVITY ISN'T THE TEAM EFFORT is a calculation determined by the team to evaluate the complexity and perhaps the time to get something done


问:
What does a node.js web application's setup look like on a real production server?
Being new to node js magic world, i'm wondering how does a web application's setup look like on a real production server?
So far all tutorials, create the js file that is started from a console...and that's it.
Anyone has created a real world web app that uses node js in the back end? Can you please describe how is it setup, and how reliable this infrastructure is ? I'm coming from the asp.net and php world that require heavy web servers...and can't have a clear idea about node stuff.</p>

答:
I have came across the similar asignment where I asked to implement or create three different modules.

Web application

REST application

Node

All my web application requests are pointing to REST module which is purely Spring web service implementation. This is before node.js coming in to picture. Later I asked to add node layer in between web and REST module so that all my web applications request should route through node module and node will hand it over to REST module and vice versa. This is because looking at the business need and some specific requirement.

So my web application is having all static html implementation which are calling node.js module through jquery ajax call and on success html dom elements are filled up with some values.

Lets take an example
I have a button click event on which jquery ajax call should be called to node application. For this node application must be in running state. To run node.js application use following command.

$ node index.js

Where index.js is my main starting point for node module which has some url
e.g. getContactDetails

```<code>$(document).on("click", "#btnClick", function(event) {
      jQuery.ajax({
type : 'POST',
url : "http://nodeserver:port/appurl",
dataType :"json",
data : JSON.stringify(someJSON),
contentType : "application/json;charset=utf-8",
success : function(data) {
    /*Some code*/},
error :function(data) {
    /*Some code*/}
    });
    });
</code>```

Inside node I am giving call to REST module like below

```<code>requestObj({
            url : restUrl,
            method : "POST",
            headers : { "Content-Type" : "application/json","pubKey":composeJSON},
            body : JSON.stringify(tmp.body)
        },
        function (error, res, body) {
            indexresponseBody = JSON.stringify(JSON.parse(body).message);
        }
    );
    res.writeHead(200, {'content-type':'text/html'});
    res.write("data",indexresponseBody);
    res.end();
</code>```

ContentLicense: CC BY-SA 3.0

Body:
I have came across the similar asignment where I asked to implement or create three different modules.

Web application

REST application

Node

All my web application requests are pointing to REST module which is purely Spring web service implementation. This is before node.js coming in to picture. Later I asked to add node layer in between web and REST module so that all my web applications request should route through node module and node will hand it over to REST module and vice versa. This is because looking at the business need and some specific requirement.

So my web application is having all static html implementation which are calling node.js module through jquery ajax call and on success html dom elements are filled up with some values.

Lets take an example
I have a button click event on which jquery ajax call should be called to node application. For this node application must be in running state. To run node.js application use following command.

$ node index.js

Where index.js is my main starting point for node module which has some url
e.g. getContactDetails

$(document).on("click", "#btnClick", function(event) {
      jQuery.ajax({
type : 'POST',
url : "http://nodeserver:port/appurl",
dataType :"json",
data : JSON.stringify(someJSON),
contentType : "application/json;charset=utf-8",
success : function(data) {
    /*Some code*/},
error :function(data) {
    /*Some code*/}
    });
    });

Inside node I am giving call to REST module like below

requestObj({
            url : restUrl,
            method : "POST",
            headers : { "Content-Type" : "application/json","pubKey":composeJSON},
            body : JSON.stringify(tmp.body)
        },
        function (error, res, body) {
            indexresponseBody = JSON.stringify(JSON.parse(body).message);
        }
    );
    res.writeHead(200, {'content-type':'text/html'});
    res.write("data",indexresponseBody);
    res.end();


问:
XSLT and possible alternatives
I had a look at XSLT for transforming one XML file into another one (HTML, etc.). Now while I see that there are benefits to XSLT (being a standardized and used tool) I am reluctant for a couple of reasons

XSLT processors seem to be quite huge / resource hungry

XML is a bad notation for programming and thats what XSLT is all about.

It do not want to troll XSLT here though I just want to point out what I dislike about it to give you an idea of what I would expect from an alternative.

Having some Lisp background I wonder whether there are better ways for tree-structure transformations based upon some lisp. I have seen references to DSSSL, sadly most links about DSSSL are dead so its already challenging to see some code that illustrates it. Is DSSSL still in use? I remember that I had installed openjade once when checking out docbook stuff.

Jeff Atwood's blog post seems to hint upon using Ruby instead of XSLT.

Are there any sane ways to do XML transformations similar to XSLT in a non-xml programming language? I would be open for input on

Useful libraries for scripting languages that facilitate XML transformations

especially (but not exclusively) lisp-like transformation languages, or Ruby, etc.

A few things I found so far:

A couple of places on the web have pointed out Linq as a possible alternative. Quite generally I  any kind of classifications, also from those who have had the best XSLT experience.

For scheme http://cs.brown.edu/~sk/Publications/Papers/Published/kk-sxslt/ and http://www.okmij.org/ftp/Scheme/xml.html

答: I've worked on multiple XML processing systems that combine XSLT libraries with Java or C++ for the parts that XSLT isn't as good at. There are libraries that get very good XSLT performance even on 20 MB XML files, however XSLT has some limitation with context, variables and really complex string patterns. Each system I've worked on had a few things done in Java/C++ because context was important or some complex regex expression helped. My takeaway is that XSLT plus some additional code in your language of choice is a good way to transform XML.</p>

Title: XSLT and possible alternatives


问:
What is the general tech news website every programmer should read?
A link and a quick explanation why would be very helpful.

General tech news, I mean not like InfoQ which is too technical. Probably much more like P.SE than SO.

EDIT: site should help developers gain general knowledge about the industry, technologies, inventions, etc. Much like when we listen to the news every morning in our car to know what is happening in our world. But target audience must be either programmmers, geeks or any other persons interested in technology.

答: Slashdot, of course! Even if stories are often old news by the time they're posted there, the discussions are always quite interesting.</p>

ContentLicense: CC BY-SA 2.5


答:
If you are using XSLT to generate XML  based on the raw XSLT and some parameters that you are passing to the XSLT engine, then using a templating XML approach is much easier to understand and maintain.

I've been on a project where Moustache was used to replace XSLT and the result was much simpler base XML files that everyone could edit and adjust, rather than that project work being passed to one or two brave souls, who would sit in total silence with beads of sweat pouring off...

The template approach is not suitable for use when the base XML is also valid data in its own right, and that XSLT is being used to provide an alternative representation, or an extract from the source XML.

Title: XSLT and possible alternatives

Body:
I had a look at XSLT for transforming one XML file into another one (HTML, etc.). Now while I see that there are benefits to XSLT (being a standardized and used tool) I am reluctant for a couple of reasons

XSLT processors seem to be quite huge / resource hungry

XML is a bad notation for programming and thats what XSLT is all about.

It do not want to troll XSLT here though I just want to point out what I dislike about it to give you an idea of what I would expect from an alternative.

Having some Lisp background I wonder whether there are better ways for tree-structure transformations based upon some lisp. I have seen references to DSSSL, sadly most links about DSSSL are dead so its already challenging to see some code that illustrates it. Is DSSSL still in use? I remember that I had installed openjade once when checking out docbook stuff.

Jeff Atwood's blog post seems to hint upon using Ruby instead of XSLT.

Are there any sane ways to do XML transformations similar to XSLT in a non-xml programming language? I would be open for input on

Useful libraries for scripting languages that facilitate XML transformations

especially (but not exclusively) lisp-like transformation languages, or Ruby, etc.

A few things I found so far:

A couple of places on the web have pointed out Linq as a possible alternative. Quite generally I  any kind of classifications, also from those who have had the best XSLT experience.

For scheme http://cs.brown.edu/~sk/Publications/Papers/Published/kk-sxslt/ and http://www.okmij.org/ftp/Scheme/xml.html


问:
Implementing User Authentication on an N-Tier Web Application
I appreciate all help and feedback.  Parts bolded are critical parts if this is too verbose.  Perhaps it will help to mention I am a green developer.  I have found some useful info from related questions posted here and on Stack Overflow but nothing that felt 100%.

Background

Currently at work we are developing a web application with strict constraints set forth by the client.  Normally we are a Rails shop, but the client really wanted to work with us.  Thus to fit into their architecture we will be using ASP.NET.  We are not very experienced with ASP.NET but some of the team including myself have used .NET for desktop applications.

This application is three tiered and includes:

Public facing server(s)

Web services server(s)

Data server(s)

The client is expecting high demand and they may have multiple servers in any one of the tiers.  There is a firewall between every tier.  From my understanding this is a very common set up.

A core goal is to minimize trips over the wire from the public facing server to the database.

The Problem

How do we handle user authentication without hampering performance on an N-Tier application with potentially many servers at each layer?

What We've Done so Far

We toyed with the idea of using view state but ultimately felt like this would be a poor idea.  Of course we are not opposed to re-visiting view state, but feel that view state offers no benefits over cookies and simply makes it harder for a user to have multiple tabs of our application open.

I have been exploring the path of using the default session state with a custom implemented session store.  The default session state tends to generate multiple requests going over the wire.  Logging in and out this is okay, but when the user is using the app we do not want this.  The custom session store helps minimize impact, but not by enough.

Conclusion & Possible Idea

Since trips to the database will be inevitable on almost all requests once inside the application, perhaps giving the user a key on successful login is the best way to go.  Then when the user requests a new page, or posts a new page we could send that key with the related SQL transaction for the request and validate the key.  I believe this will simplify the code base immensely.

So to re-iterate the problem:  How do we handle user authentication without hampering performance on an N-Tier application with potentially many servers at each layer?  Does the idea above sound like a solid implementation?

Thanks,

Jonathon

答:
Maybe I'm cynical but I smell a common problem here.  They are expecting high demand and so are doing distributed everything from the get go with careful optimization.  Before they have a product.

How do they know that they will get all of this traffic?

If they get all of this traffic, how do they know that something simple won't scale?

The right solution is to implement a simple function that behind the scenes does a simple database request, but which later can be switched out for something fancy.  And then don't worry about it until there is a proven problem.  A decade ago I did something similar, and we didn't hit scaling problems until 100k dynamic pages/hour.  And when we hit problems there, it wasn't hitting the login that was the problem!

Yes, I could suggest lots of fancy architectures that scale better.  I've built some as well.  But until you need to go there, assume that you won't.


问:
Sort rectangles in a grid based on a comparison of the center point of each
If I have a grid of rectangles and I move one of the rectangles, say above and to the left of another rectangle, how would I resort the rectangles?

Note the rectangles are in an array, so each rectangle has an index and a matching tag. All I really need to do is set the proper index based on the rectangles new center point position within the rectangle, as compared with the center point position of the other rectangles in the grid. Here is what I am doing now in pseudo code (works somewhat, but not accurate):

```<code>-(void)sortViews:myView {
int newIndex;
// myView is the view that was moved.
[viewsArray removeObject:myView];
[viewsArray enumerate:obj*view]{
    if (myView.center.x > view.center.x) {
        if (myView.center.y > view.center.y) {
            newIndex = view.tag -1;
            *stop = YES;
        } else {
            newIndex = view.tag +1;
            *stop = YES;
        }
    } else if (myView.center.x < view.center.x) {
        if (myView.center.y > view.center.y) {
            newIndex = view.tag -1;
            *stop = YES;
        } else {
            newIndex = view.tag +1;
            *stop = YES;
        }
    }
}];
if (newIndex < 0) {
    newIndex = 0;
} else if (newIndex > 5) {
    newIndex = 5;
}
[viewsArray insertObject:myView atIndex:newIndex];
[self arrangeGrid];
}
</code>```

答:
Not really an answer, but it won't fit in a comment:

First, what you're doing looks fine to me.  I'm not familiar with the language, but arrays are usually very fast.

If you have a large number of rectangles, a Dictionary or Map, using x/y keys would be more elegant.  Then you can find your entry more quickly, remove it without moving 1000's of elements around in the array, and insert without moving elements around.  (I'd like to they'd be much faster with large lists, but I've been embarrassed by absurdly fast arrays too many times in benchmarks.)  (Be sure to remove the rectangle first, then change the key, then re-add it.)

If you stick with an array, you could speed things up with binary searches to find the rectangle and to figure out where to put it.  You could also speed things up by moving only the elements between the removal point and the insertion point.

Your language seems to do a lot of work for you: you may want to check out what it is doing and what else it can do for you.  (Your "array" may already be a dictionary/map--or something better.  You may be able to get it to move an element in one go, rather than removing and adding, thus saving moving a lot of entries.)


答:
I work on a node.js web application that is not yet in production, but we do run a development server setup similarly to how I would setup production.

It's a Linux server (CentOS specifically, but any distro would do) with a service account dedicated for running the web app.  Deployment is as simple as SCP'ing the tarball file up to the server and running:

```<code>$ npm stop <app name>
$ npm install ./<app name>-<version>.tgz
$ npm start <app name>
</code>```

npm allows for life cycle scripts to be setup via package.json which is how npm stop and npm start are implemented.  By default, npm start calls node server.js if there is a server.js in the top-level directory.  You can define your own start script easily via package.json.

We use the daemon module when starting up via npm start in order to run the app in the background, totally disconnected, with output redirected to a log file.  Starting directly via server.js, however, skips the daemon step so I have an interactive terminal in development.

Since we use npm for packaging and installation, the code ends up living under $HOME/node_modules/.  And again, this runs under a dedicated user account, so I know exactly what modules are and are not available at runtime.

In order to leverage multiple CPU's, the server.js script will fork a worker (via the cluster module) for each CPU and monitor them for death.  If a worker dies, the master process restarts it.  There are modules out there to kick off your app and auto-restart if it dies, however, given that our master does no work except for baby sitting the workers, I don't bother watching the master.  The game of "who watches the watchers" could go on infinitely.

When going to production, there are only three more elements to build out, which we have not done yet:

Load balancing, which is not part of the app itself and has nothing to do with node.js

An init script to start and stop the service when the server box is rebooted.

When shutting down the service to install a new release, we need to remove it from the load balancer pool and then put it back in.

Title: What does a node.js web application's setup look like on a real production server?

Body:
Being new to node js magic world, i'm wondering how does a web application's setup look like on a real production server?
So far all tutorials, create the js file that is started from a console...and that's it.
Anyone has created a real world web app that uses node js in the back end? Can you please describe how is it setup, and how reliable this infrastructure is ? I'm coming from the asp.net and php world that require heavy web servers...and can't have a clear idea about node stuff.</p>

Body:
I work on a node.js web application that is not yet in production, but we do run a development server setup similarly to how I would setup production.

It's a Linux server (CentOS specifically, but any distro would do) with a service account dedicated for running the web app.  Deployment is as simple as SCP'ing the tarball file up to the server and running:

$ npm stop <app name>
$ npm install ./<app name>-<version>.tgz
$ npm start <app name>

npm allows for life cycle scripts to be setup via package.json which is how npm stop and npm start are implemented.  By default, npm start calls node server.js if there is a server.js in the top-level directory.  You can define your own start script easily via package.json.

We use the daemon module when starting up via npm start in order to run the app in the background, totally disconnected, with output redirected to a log file.  Starting directly via server.js, however, skips the daemon step so I have an interactive terminal in development.

Since we use npm for packaging and installation, the code ends up living under $HOME/node_modules/.  And again, this runs under a dedicated user account, so I know exactly what modules are and are not available at runtime.

In order to leverage multiple CPU's, the server.js script will fork a worker (via the cluster module) for each CPU and monitor them for death.  If a worker dies, the master process restarts it.  There are modules out there to kick off your app and auto-restart if it dies, however, given that our master does no work except for baby sitting the workers, I don't bother watching the master.  The game of "who watches the watchers" could go on infinitely.

When going to production, there are only three more elements to build out, which we have not done yet:

Load balancing, which is not part of the app itself and has nothing to do with node.js

An init script to start and stop the service when the server box is rebooted.

When shutting down the service to install a new release, we need to remove it from the load balancer pool and then put it back in.


问:
What is the exact semantic of reduce in clojure?
The Clojure docs regarding (reduce f val coll) state:

If val is supplied, returns the result of applying f to val and the
  first item in coll, then applying f to that result and the 2nd item,
  etc.

So I tried:

```<code>(reduce str ["s1" "s2"] "s3")
</code>```

Which leads to:

```<code>"[\"s1\" \"s2\"]s3"
</code>```

However, when I try

```<code>(apply str ["s1" "s2"])
</code>```

I get:

```<code>"s1s2"
</code>```

So why does the vector get converted into its string representation?

答:
For a "picture" view for others who may see this question. Clojure's reduce is a left fold. For Haskell programmers foldl.

It creates the following structure

```<code>(reduce - 0 (range 1 3))
(- (- (- 0 1) 2) 3)
</code>```

or infix

```<code>(((0 - 1) - 2) - 3)
</code>```

The intuition being it's a left fold because the parens drift towards the left

Body:
For a "picture" view for others who may see this question. Clojure's reduce is a left fold. For Haskell programmers foldl.

It creates the following structure

(reduce - 0 (range 1 3))
(- (- (- 0 1) 2) 3)

or infix

(((0 - 1) - 2) - 3)

The intuition being it's a left fold because the parens drift towards the left


问:
Not copyrighting code and then reusing functions later
I'm coding something for my job to copy directories and then use regex to make all the filenames uniform.  I'm an undergrad student programmer for my university and I'm not sure what a professional coder would consider reasonable in this case. My job is mostly to implement mathematical research.  The current assignment is outside what I've been doing and seems like it would be really useful to have some of the functions available in case I (most likely) encounter a similar assignment at some point in my career in the future.  It's going to be really useful because the current filenames are so screwed right now that the admin assistants can't really keep up (and even trying to do so might just cause more human error).  I'm thinking that it may not overall be useful outside the current assignment because the regex will be so customised to the way the file are incorrectly named.

I'm wondering if this is simple work for a pro coder, and therefore I'm making this program to be much more important in my head than it actually is, or if this is something that a coder would really want to copyright or otherwise retain the ability to use this whenever and wherever else they feel like.  They've already told me that there is no question that I'll be given credit for the work, which I'm excited about.  My only concern was whether I should be thinking about reusing this code later or if this task is so generic that a pro coder would laugh about keeping the rights to such code.

This thread was interesting but seems different from my situation:

How can I reuse generic code for consulting between companies?

EDIT:

Florida, USA

答:
The other answers address the legal aspects of the problem & @MichaelT is (AFAIK) correct - it's a work for hire & your employer owns it.

From a practical point of view, you're right in thinking that this code is likely so simple and generic that it's not worth paying attention to who owns it.  It's a minor part of an academic project where the 'real work' has nothing to do with file management.  It's probably only about a dozen lines of shell script that nobody's ever going to notice.

As long as you don't try selling it as a product or publishing it publicly, keep it around for reference.  Use it where you need to.  Nobody's ever going to notice or care.  It's the IP equivalent of jaywalking.


答:
Your manager is asking (or telling) your team to work extra hours.  While removing bottlenecks and gaining efficiencies may improve your velocity somewhat, the only way to get that increase (40%) is by working longer hours, becuase you need to stuff in more units of work in that time period.

Let's take a scenario.

For a two week interation lets say 10 days.  Utopia would be 8 hours a day, with a story point being abstracted to a work day.  So, from the top, your velcoity would be 8.  But, relistically people are probably getting in 6 good hours a day with email, meetings, bathroom breaks, etc.  So now your at a 6 per developer.  So your baseline is 6.  Let's say you want people to work overtime, now there at 10 hours a day.  So, that would be 10 velocity points per developer.

Your velocity will always fluctuate, maybe it was low because you had to deal with a lot of bugs during that iteration, maybe requirements were missing, maybe someone got sick for a few days.  Maybe it was high because work was overestimated or your team put in extra hours.

But if your at a stable 50, really to get to 70 will require extra hours.

Title: Is a large increase in velocity realistic in a Scrum environment?

Body:
My manager has recently really been pushing to use velocity as a target and measure of productivity. We are currently working at an average velocity of 50 story points. My manager wants us to increase it by 40% to 70 story points (with no increase in team members). If we don't achieve this increase he wants us to deliver a full break down explaining why.

The whole idea of measuring team performance by velocity and using it as a target seems wrong to me, but I am finding it difficult to explain why. Any help? Why isn't this the right way to measure and incentivize productivity?


问:
Is MultiTasking in a development environment worthwhile?
If we get assigned to do multiple works simultaneosly, is it good for growth for a developer?

If there is a development project and if you are assigned to work on a maintenance project as well, is it good for the growth or will it inhibit the progress?

答:
Working on multiple initiatives simultaneously is more likely than not going to institute a good amount of context switching.  Context switching is bad, generally.  As @Dan answered, having multiple initiatives allows you to have something else to fall back on when you need a break, as long as you have the convenience of doing so.

In terms of developer growth, it's good for a developer to be well versed in many areas of development, if that's what you're getting at, but try to focus on one initiative at a time to inhibit the chance of constant context switching and the pitfalls that come along with it.


问:
To rewrite or slowly refactor old C++ project
Our team has recently inherited a relatively large project from another company (~250k lines). It was developed using C++Builder and we intend to port the Ui side to Qt. Most of the Ui code is separate from the business logic (yay!) but the logic side is quite a mess.

There is a lot of diamond inheritance going on (virtual inheritance thankfully) but it makes understanding the code quite difficult to do.

We've got very little documentation to go on, what's there is out of date (comments included).

I generated class diagrams using Doxygen, here's the most complex one (I had to remove most of  the class names but kept some of the more important ones and kept the standard C++ data types and std classes, yes, they inherit from std)

So far we've been able to convert the base program to Qt and we're at a point where we can start converting the program's functionality bit by bit. Problem is, is it worth it long term? We would like to be maintaining this software as our own long term.

Is there a general approach we should take to untangling this kind of inheritance mess or should we simply redesign from scratch and only keep bits and pieces of the existing code as we go?

EDIT: Some more info

Zavior posted a link to an article about why we should not start from scratch but Ptolemy also brought up some good questions and I'd like to add some information about our situation.

The program we have is not 'bug free.' There are known issues that users have workarounds for most. There is no 'list' of these issues, that is currently being compiled by talking to all the existing users one by one as they tend to keep things to themselves.

We are all new developers to this project. Our only resource is a developer who started working on the project about half-way through its lifetime. He is available via e-mail/chat mostly. He has also put together some documentation on how some parts of the code work.

The program has only been used as an internal tool so far. We would like to make it commercially viable.

EDIT 2:

One of the most important things we want to do is have the program be in Qt. It's currently using the VCL framework from C++Builder that no one on our team is familiar with and we only have 1 license for. It's during my work porting from VCL to Qt that I found the messy code structure and question the decision to 'convert' vs redo.

答:
Being an Delphi developer myself (and the VCL is written on Object Pascal), I agree with others that you must first get acquainted with VCL and the application codebase before get into radical decisions.

VCL itself is mostly tied with Windows API concepts, while creating an very precise OO translation of it. It's different of QT which have an multiplatform objective.

Regarding the business logic, decypher it (from the code) to the point you can write an very precise spec of the RULES (or, in ther words, an precise notion of real problems the codebase targeted to represent and solve). With that, you'll have an direction to walk.


答:
It's good for you (within reason).

Working on maintenance projects will reinforce the need for good programming habits and will expose you to other techniques (both good ones to mimic and bad ones to avoid).  It will also pound into your head the notion that programming choices have consequences and you need to think about the next person to edit the code.

Likewise, a limited amount of context switching is not necessarily harmful - it gives you the opportunity to work on something different when the current task/project starts getting stale.  The challenge is to ensure that the switches are under your control and that you have sufficient time for both tasks.

My idea of limited switching would be on the order of a couple switches per week, depending on circumstances.

Title: Is MultiTasking in a development environment worthwhile?

Body:
If we get assigned to do multiple works simultaneosly, is it good for growth for a developer?

If there is a development project and if you are assigned to work on a maintenance project as well, is it good for the growth or will it inhibit the progress?


问:
Why are there no PUT and DELETE methods on HTML forms?
HTML4 / XHTML1 allows only GET and POST in forms, now it seems like HTML5 will do the same. There is a proposal to add these two but it doesn't seem to be gaining traction.

What were the technical or political reasons for not including PUT and DELETE in HTML5 specification draft?

答:
This is a fascinating question. The other answers here are all speculative, and in some cases flat-out incorrect. Instead of writing my opinion here, I actually did some research and found original sources that discuss why delete and put are not part of the HTML5 form standard.

As it turns out, these methods were included in several, early HTML5 drafts (!), but were later removed in the subsequent drafts. Mozilla had actually implemented this in a Firefox beta, too.

What was the rationale for removing these methods from the draft? The W3C discussed this topic in bug report 10671. Mike Amundsen argued in favor of this support:

Executing PUT and DELETE to modify resources on the origin server is straight-forward for modern Web browsers using the XmlHttpRequest object. For unscripted browser interactions this not so simple. [...]

This pattern is required so often that several commonly-used Web frameworks/libraries have created a "built-in" work-around. [...]

Other considerations:

Using POST as a tunnel instead of using PUT/DELETE can lead to caching mis-matches (e.g. POST responses are cachable, PUT responses are not(6), DELETE responses are not(7))

Using a non-idempotent method (POST) to perform an idempotent operation (PUT/DELETE) complicates recovery due to network failures (e.g. "Is is safe to repeat this action?").

[...]

It's worth reading his entire post.

Tom Wardrop also makes an interesting point (href):

HTML is inextricably bound to HTTP. HTML is the human interface of HTTP. It's therefore automatically questionable why HTML does not support all relevant methods in the HTTP specification. Why can machines PUT and DELETE resources, but humans cannot? [...]

It's contradictory that while HTML goes to great lengths to ensure semantic markup, it has to date made no such effort to ensure semantic HTTP requests.

The bug was eventually closed as Won't Fix by Ian Hickson, with the following rationale (href):

PUT as a form method makes no sense, you wouldn't want to PUT a form payload. DELETE only makes sense if there is no payload, so it doesn't make much sense with forms either.

However, that's not the end of the story! The issue was closed in the W3C bug tracker and escalated to the HTML Working Group issue tracker:

https://www.w3.org/html/wg/tracker/issues/195

At this point, it seems that the main reason why there is no support for these methods is simply that nobody has taken the time to write a comprehensive specification for it.

ContentLicense: CC BY-SA 4.0


问:
Future of a ServiceStack based Solution in the Context of Licensing
I just want someone to clarify the following questions as Demis Bellot had announced a couple of weeks ago that ServiceStack would go commercial. Refer link below.

https://plus.google.com/app/basic/stream/z12tfvoackvnx1xzd04cfrirpvybu1nje54

(Please note that when I say ServiceStack or SS I refer to all associated SS libraries such as ServiceStack.Text, etc.)

If I have a solution already developed using ServiceStack today will I have to purchase a license once SS goes commercial even if I don't upgrade the SS binaries to the commercial release version?

Will previous versions of SS (prior to commercial licensing) always be opensource and use the same license as before?

If I fork SS today (prior to commercial licensing) on Github, would it be illegal to maintain that after SS goes commercial?

If the answer to question 2 is yes, then would I still be able to fork a previous version after SS goes commercial without worrying about the commercial license (all the while maintaining and releasing the source to the public)?

答:
The best way to get a definitive answer is to ask them. But I will give you my interpretation anyhow.

Basically, they cannot revoke the license they granted you on the existing code.  And from my reading of the message you linked to, they expect to keep the existing BSD based code available but will not be doing any work on it.

So to take your questions:

If I have a solution already developed using ServiceStack today will I have to purchase a license once SS goes commercial even if I
  don't upgrade the SS binaries to the commercial release version?

No you will not need to purchase a license, just keep using the existing BSD licensed version.

Will previous versions of SS (prior to commercial licensing) always be
  opensource and use the same license as before?

Yes. They have granted you a license on the existing releases.

If I fork SS today (prior to commercial licensing) on Github, would it
  be illegal to maintain that after SS goes commercial?

No it would not be illegal.

If the answer to question 2 is yes, then would I still be able to fork
  a previous version after SS goes commercial without worrying about the
  commercial license (all the while maintaining and releasing the source
  to the public)?

Yes, you may fork the old version. But remember they are under no obligation to keep the old code around so you may discover that suddenly the old version is no longer on their site but that doesn't change the rights they granted you to use the old version.

I will repeat my earlier statement: Ask them. Especially if you are building a commercial solution, it's worth getting their official position on the licensing of the existing code.


问:
Why we use virtual and override keywords in c#
Can anyone explain me what's the point of overriding base class implementations (if its not abstract), because it's not ethical move to modify features of the parent class according to the wishes of derived classes. The best way is to make the base classes abstract and carry on the inheritance chain. Whereas when designing a class hierarchy initially we gather or elicit  all the essential requirements/features that should be belonged to a base class. Therefore, in a middle of a project we do not need to change base class implementations. According to my knowledge, base class implementation should be a constant. Thus, under this aspect, there's no real use of "override" keyword in c#. If it's not so please explain me with an example.</p>

答:
Here's a non-abstract class which does some processing, and a sub class which only does processing at certain times of day.

```<code>class Foo
{
    public virtual bool IsReadyToProcess()
    {
        return true;
    }
    public void Process()
    {
        if (!IsReadyToProcess()) throw new Exception("Not ready");
        else
          // Process
    }
}

class TimeboundFoo : Foo
{
    public TimeboundFoo(int hour) { Hour = hour; }

    public int Hour { get; private set; }

    public override bool IsReadyToProcess()
    {
       return DateTime.Now.Hour == Hour;
    }
}
</code>```

Usage:

```<code>List<Foo> foos = new List<Foo>();
foos.Add(new Foo());
foos.Add(new TimeboundFoo(12));

foreach (var foo in foos)
{
   if (foo.IsReadyToProcess()) foo.Process();
}
</code>```

At noon, it'll process both Foo objects, but at any other hour it'll only process the one.
It's a very contrived example, but you can generalize from here.

Body:
Here's a non-abstract class which does some processing, and a sub class which only does processing at certain times of day.

class Foo
{
    public virtual bool IsReadyToProcess()
    {
        return true;
    }
    public void Process()
    {
        if (!IsReadyToProcess()) throw new Exception("Not ready");
        else
          // Process
    }
}

class TimeboundFoo : Foo
{
    public TimeboundFoo(int hour) { Hour = hour; }

    public int Hour { get; private set; }

    public override bool IsReadyToProcess()
    {
       return DateTime.Now.Hour == Hour;
    }
}

Usage:

List<Foo> foos = new List<Foo>();
foos.Add(new Foo());
foos.Add(new TimeboundFoo(12));

foreach (var foo in foos)
{
   if (foo.IsReadyToProcess()) foo.Process();
}

At noon, it'll process both Foo objects, but at any other hour it'll only process the one.
It's a very contrived example, but you can generalize from here.


答:
In general, you just said that you would refactorate it because it is a mess. Well, users want programs that run, do what they want, etc. They don't ask for new programs because the code of the older one (that they don't even see) is a mess.

If the old program is preventing you from doing something, then, perhaps, you could spend time, money, etc., doing it from scratch. But keep in mind that there are many points against it:

1 - bad or not, users know how to work-around some bugs. Even if you rewrite the app and it's perfect, your users won't know how to handle it in the beginning. No one likes changes, even for better.

2 - users know work-arounds = means that they are not documented, so you might miss some functionality when trying to do the new software (because it won't be in the old code, or someone will miss to tell you that)

3 - you have to have gains for the user to justify rewriting it: doing it all over to end up with the same system means that there is no benefit for the user

4 - new software will have new bugs, and that will play against you

5 - the users don't want something new, another system, etc., instead of just redoing what they already have ?

Title: To rewrite or slowly refactor old C++ project

Body:
Our team has recently inherited a relatively large project from another company (~250k lines). It was developed using C++Builder and we intend to port the Ui side to Qt. Most of the Ui code is separate from the business logic (yay!) but the logic side is quite a mess.

There is a lot of diamond inheritance going on (virtual inheritance thankfully) but it makes understanding the code quite difficult to do.

We've got very little documentation to go on, what's there is out of date (comments included).

I generated class diagrams using Doxygen, here's the most complex one (I had to remove most of  the class names but kept some of the more important ones and kept the standard C++ data types and std classes, yes, they inherit from std)

So far we've been able to convert the base program to Qt and we're at a point where we can start converting the program's functionality bit by bit. Problem is, is it worth it long term? We would like to be maintaining this software as our own long term.

Is there a general approach we should take to untangling this kind of inheritance mess or should we simply redesign from scratch and only keep bits and pieces of the existing code as we go?

EDIT: Some more info

Zavior posted a link to an article about why we should not start from scratch but Ptolemy also brought up some good questions and I'd like to add some information about our situation.

The program we have is not 'bug free.' There are known issues that users have workarounds for most. There is no 'list' of these issues, that is currently being compiled by talking to all the existing users one by one as they tend to keep things to themselves.

We are all new developers to this project. Our only resource is a developer who started working on the project about half-way through its lifetime. He is available via e-mail/chat mostly. He has also put together some documentation on how some parts of the code work.

The program has only been used as an internal tool so far. We would like to make it commercially viable.

EDIT 2:

One of the most important things we want to do is have the program be in Qt. It's currently using the VCL framework from C++Builder that no one on our team is familiar with and we only have 1 license for. It's during my work porting from VCL to Qt that I found the messy code structure and question the decision to 'convert' vs redo.


答:
When looking at large scale projects (specially the ones you haven't worked on), It is very important to realize one thing. Nobody should expect you to fully understand it. You should live by the mantra of divide and conquer. That is the technique I have always used it has yet to let me down.

Consider yourself a surgeon presented with a patient who has multiple severe injuries that require your attention. Lets say you have some infection in a wound in the leg. This would be analogous to a bad library/code you want to get rid of from your code. You'd first try to establish the extent of the infection. The analogy is a quick grep to see how many files actually use that library/code and what is the nature of use. This is a significant step in the whole process and usually the most cumbersome. But after doing this what you accomplish is the identification of your boundaries and these are key. Once you know the extents you can apply anesthesia appropriately (assuming local anesthesia as it better suits the example). In terms of code, this could be interfaces at the appropriate places close to the boundary, unit tests etc. Building interfaces and creating unit tests at the boundary lets you mark your boundary. After marking your boundary, you should be more or less free to attack the infection/bad code which every way however way you like while your interfaces and boundary unit tests ensure that you never lose your way. Once done with all the modifications within your boundary i.e: all the denting and painting, your application should behave as it did without having any knowledge what so ever of any any operation ever taking place.

You then repeat this whole process for the next library/bad piece of code until you target them all. So in summary picking your battles and localizing your focus is paramount, when tackling the big ugly beasts of such nature. Good luck.


问:
Best practice in application design / SQL authentication
I am currently involved in the implementation/design of an existing application for a large scale customer. The application has a similar model as e.g. vCenter Server whereby a number of components store information in and extract information and workflows form a central database. The environment is managed from a console application which uses a windows service to connect to the database.

Due to security considerations SQL Authentication is not an option, but the application does support Windows Authentication. However when using windows authentication it passes the credentials of the user who is using the management console application on to the database in stead of using the service account under which the service runs.

This results in the situation where the security roles as they are defined within the application (AD users/groups mapped to certain permissions) requires these AD objects to also have a SQL Server login and certain permissions on the database (db-writer for certain tables, depending on the specific permissions in the app).

Apart from the additional administration, this also creates a security risk IMO because the whole point of the application security roles in this specific application is to allow users access to only a part of a certain table (e.g. a subset of the objects). But since they now have a SQL login and db_writer on that entire table they could bypass the app and with a direct connection to the database they could read/alter records they would not be allowed to view/manipulate through the application.

This risk could then (partly) be mitigated by restricting access to the database on a network level, or possibly use triggers to check the calling hostname and program name, but as far as I know that is not completely safe.

The only benefit as is presented to me is there is now a full audit trail available in SQL server on exactly who did what. But this is already implemented in the application as well so it seems kind of moot to me.

I have been frantically searching for any info on this and what would be the best practice. I can only find ASP / Web based stuff but nothing regarding this type of application.

Is it really the best way to go with passing through authentication to SQL server or should the app handle authorization and send all database requests using the service account?

P.S.: This is my first question on stackexchange, if I posted on the wrong sub-site or you find my question inappropriate, please just let me know.

答: In general, if you are using this model, you should not use any access method except stored procs and the rights shoud be on the procs themselves and never directly on a table or view.  This means no dynamic SQL of any kind (including in procs). That way users who directly access the database can still only do the things they are allowed to do by the application. This is one place where using an ORM would be a disaster.  There shoud be no SQL Server logins. Instead the users should be in windows groups that are given rights based on what they are allowed to do. These rights could consist of read rights for a table but no insert/updates or deletes that are not done through executing a stored proc. They would get exec rights only to the procs that their user group should be able to run in the application. </p>


问:
What is the correct implementation of <meta> element in HTML5?
I've been watching a video to learn HTML. I know about HTML but I just wanted to refresh my knowledge. The author declared that he is using HTML5 because the doctype was:

```<code><!doctype html>
</code>```

but I noticed that the author used the meta element in a different style that I get used to, he used it without the the forward slash to close the element as follows:

```<code><meta charset="utf-8">
</code>```

and what I know about this is that it should be like the follwing:

```<code><meta charset="utf-8" />
</code>```

Which one of the above elements is considered HTML5? I tried to search online but it seems that every web designer has a different opinion which confused me. I like standards.

答:
The notion of self-closing tags like this:

```<code><meta charset="utf-8" />
</code>```

Is an idea that was brought forward from XHTML. XHTML was an effort by some at the W3C to create a XML-compatible dialect of HTML. It was based on HTML 4.0, but was modified only for XML compatibility. XHTML proved to have a number of problems, and many user agents (browsers) were unable to cope with XHTML documents delivered according to the standard's specifications and required several "hacks" just to keep browsers from dropping to "quirks mode."

HTML5 has no relation to XML. It too is based on HTML 4.0, but it disposed of the XML boondoggle that came out of the XHTML effort.

Self-closing tags in HTML5 are valid, but unnecessary.

Body:
The notion of self-closing tags like this:

<meta charset="utf-8" />

Is an idea that was brought forward from XHTML. XHTML was an effort by some at the W3C to create a XML-compatible dialect of HTML. It was based on HTML 4.0, but was modified only for XML compatibility. XHTML proved to have a number of problems, and many user agents (browsers) were unable to cope with XHTML documents delivered according to the standard's specifications and required several "hacks" just to keep browsers from dropping to "quirks mode."

HTML5 has no relation to XML. It too is based on HTML 4.0, but it disposed of the XML boondoggle that came out of the XHTML effort.

Self-closing tags in HTML5 are valid, but unnecessary.


问:
Which is the better: a <= b or a < b+1
For loops are usually inclusice, exclusive, meaning that you start at the bottom, and stops when you reach, but don't to the top.
In Python:

```<code>for i in range(0,a):
    print(i)
</code>```

would print 0 through a-1.
The same applies for Java:

```<code>for(int i = 0; i < a; i++){
    System.out.println(i);
}
</code>```

would also print 0 through a-1, allthough the syntax is somewhat clearer.

So what if you want to print every number up to a, inclusive?
Would you write

```<code>for(int i = 0; i <= a; i++){
    System.out.println(i);
}
</code>```

or

```<code>for(int i = 0; i < a + 1; i++){
    System.out.println(i);
}
</code>```

I guess the first makes the most sense, you're looping while i is less or equals to a, but the less than sign could easily be overlooked. The a + 1 isn't that easy to miss, in my opinion.

So my question is: Is there a better alternative of the two, and is there a convension for this thing?

EDIT:

I just want to point out that i'm talking about integers here.

答:
The best convention is readability: Write code as close to your intent as possible.

If you mean: i should be less than or equal to a, then write i <= a.

If you mean: i should be less than a+1, then write i < a+1.

Title: Which is the better: a <= b or a < b+1


问:
In what situations does it make sense to use an enumeration when writing object-oriented code?
Enumerations1 are often associated with procedural code rather than object-oriented code. They tend to give rise to similar switch statements scattered through the code, and in general, these are replaced by polymorphism in object-oriented code.

For example, see Replace Type Code with Class, Replace Type Code with Subclasses, and Replace Type Code with State/Strategy in Refactoring by Martin Fowler. Closely related, see Replace Conditional With Polymorphism in the same volume; Bob Martin also has quite a bit to say on the disadvantages of switch statements in Clean Code (for example, heuristic G23 Prefer Polymorphism to If/Else or Switch/Case).

However, since object-orientation, like any other good paradigm, can be a powerful tool but is not a silver bullet, are there times when using an enumeration is a good decision?

1I use this term broadly; not just for something which is strictly an enum in a C-based language, but for any set of entities that are used to represent it (a class with a set of static members, etc...).

答:
Yes, there are valid uses of enumerations, even in systems which are primarily object-oriented.

In a layered architecture, an enumeration can be valuable in keeping. the separation of concerns between layers or modules. For example, a lexer and a parser may talk to each other in tokens, would could be some sort of enumeration.

Similarly, in a service-oriented architecture, when there is a reason for some sort of type code to cross multiple services and this cannot accomplished with multiple events instead, there may be good reason to use an enumeration.

On a little different note, it may be a useful temporary measure in emergent design in which you are waiting to make sure you get the abstract right before moving to a polymorphic solution.

But still, use enumerations with care.


答:
Say what you mean.

If you mean that the loop should run while the index variable is less than or equal to a, say that.

the less than sign could easily be overlooked

The <= operator is very common, particularly in loops. Trust your audience to be able to correctly read correctly written code. Don't avoid the natural solution simply because of a perceived possibility that some unknown future reader might need to get their eyes checked.

The a + 1 isn't that easy to miss

It's not that easy to understand, either. What would you think if you saw the code that you're proposing? I'm pretty sure I'd think something like:

Why are we talking about a + 1 when the loop obviously should run up to a? Oh, wait... I'm looking through the code, and this guy seems to have a phobia about <=... It doesn't appear anywhere in the code, and I see a few places where he goes out of his way to avoid it...

For loops are usually inclusice, exclusive

That assumption is incorrect. For loops continue while the looping condition is true.

The Python example you give is "inclusive, exclusive" only because Python's range(0,a) happens to generate the list 0..a-1. The whole "inclusive, exclusive" idea is a red herring -- it only applies because range() happens to work that way.

You could easily write your own range-like function that returned 0..a inclusive and use that to control your loop. Or you could supply your own list instead of relying on range() to generate the list:

```<code>list = [1, 2, 3]
for i in list
   ...
</code>```

In this case the loop will execute three times, once for each value in list. In other words, it's not the for loop that's excluding a in your example, but rather range().

Title: Which is the better: a <= b or a < b+1

Body:
For loops are usually inclusice, exclusive, meaning that you start at the bottom, and stops when you reach, but don't to the top.
In Python:

```<code>for i in range(0,a):
    print(i)
</code>```

would print 0 through a-1.
The same applies for Java:

```<code>for(int i = 0; i < a; i++){
    System.out.println(i);
}
</code>```

would also print 0 through a-1, allthough the syntax is somewhat clearer.

So what if you want to print every number up to a, inclusive?
Would you write

```<code>for(int i = 0; i <= a; i++){
    System.out.println(i);
}
</code>```

or

```<code>for(int i = 0; i < a + 1; i++){
    System.out.println(i);
}
</code>```

I guess the first makes the most sense, you're looping while i is less or equals to a, but the less than sign could easily be overlooked. The a + 1 isn't that easy to miss, in my opinion.

So my question is: Is there a better alternative of the two, and is there a convension for this thing?

EDIT:

I just want to point out that i'm talking about integers here.

Body:
Say what you mean.

If you mean that the loop should run while the index variable is less than or equal to a, say that.

the less than sign could easily be overlooked

The <= operator is very common, particularly in loops. Trust your audience to be able to correctly read correctly written code. Don't avoid the natural solution simply because of a perceived possibility that some unknown future reader might need to get their eyes checked.

The a + 1 isn't that easy to miss

It's not that easy to understand, either. What would you think if you saw the code that you're proposing? I'm pretty sure I'd think something like:

Why are we talking about a + 1 when the loop obviously should run up to a? Oh, wait... I'm looking through the code, and this guy seems to have a phobia about <=... It doesn't appear anywhere in the code, and I see a few places where he goes out of his way to avoid it...

For loops are usually inclusice, exclusive

That assumption is incorrect. For loops continue while the looping condition is true.

The Python example you give is "inclusive, exclusive" only because Python's range(0,a) happens to generate the list 0..a-1. The whole "inclusive, exclusive" idea is a red herring -- it only applies because range() happens to work that way.

You could easily write your own range-like function that returned 0..a inclusive and use that to control your loop. Or you could supply your own list instead of relying on range() to generate the list:

list = [1, 2, 3]
for i in list
   ...

In this case the loop will execute three times, once for each value in list. In other words, it's not the for loop that's excluding a in your example, but rather range().


答:
Enums have basically two purposes:

They help you enforce type safety

They can act as a container for
mutually-exclusive constants

Given those purposes, of what use are enums, even in object oriented languages?

In my opinion coding is all about finding the right way to express something in a specified context.

Often you don't have the need for a fully blown class. You don't introduce a class if you need to encapsulate constant, static data without or with only minimal behaviour. An enum is a better way to express your semantical needs rather than to derive it from the type of subclass, which is pretty much the only alternative involving polymorphism (and leads to switch statements on the types of subclasses as well).

Further, you keep control over the available values all the time. You cannot just put good old Liskov to use and sneak in another subclass with new behaviour. In some scenarios, that's a very much desired behaviour. One should also note that in some languages like Java enums can carry behaviour. So they can bring the behaviour you want right to the place you want it to be. As Jon Skeet put it:

An enum in Java is a fixed set of objects, basically. The benefit is
  that you know that if you have a reference of that type, it's always
  either null or one of the well-known set.

Practically speaking, in most cases where you'd just return arbitrary well-defined values (like error codes) you should switch to an enum to enforce type safety. This way you limit the amount of failure that is introduced by returning a wrong value by accident as the compiler can check it. Especially if there's little need for behaviour and the associated data is static.

Title: In what situations does it make sense to use an enumeration when writing object-oriented code?

Body:
Enumerations1 are often associated with procedural code rather than object-oriented code. They tend to give rise to similar switch statements scattered through the code, and in general, these are replaced by polymorphism in object-oriented code.

For example, see Replace Type Code with Class, Replace Type Code with Subclasses, and Replace Type Code with State/Strategy in Refactoring by Martin Fowler. Closely related, see Replace Conditional With Polymorphism in the same volume; Bob Martin also has quite a bit to say on the disadvantages of switch statements in Clean Code (for example, heuristic G23 Prefer Polymorphism to If/Else or Switch/Case).

However, since object-orientation, like any other good paradigm, can be a powerful tool but is not a silver bullet, are there times when using an enumeration is a good decision?

1I use this term broadly; not just for something which is strictly an enum in a C-based language, but for any set of entities that are used to represent it (a class with a set of static members, etc...).


答:
Virtual/abstract methods and overriding are commonly used in. Template pattern.

The template pattern provides a way to define what you think would be a good general guideline for a class to follow, but you allow future implementers to be more specific, or even unique in their way of doing something.

Title: Why we use virtual and override keywords in c#

Body: Can anyone explain me what's the point of overriding base class implementations (if its not abstract), because it's not ethical move to modify features of the parent class according to the wishes of derived classes. The best way is to make the base classes abstract and carry on the inheritance chain. Whereas when designing a class hierarchy initially we gather or elicit  all the essential requirements/features that should be belonged to a base class. Therefore, in a middle of a project we do not need to change base class implementations. According to my knowledge, base class implementation should be a constant. Thus, under this aspect, there's no real use of "override" keyword in c#. If it's not so please explain me with an example.</p>


答:
Less than or equal is 1 assembler instruction.

```<code>a <= b
</code>```

On the X86 family of processors the above would be something like:

```<code>MOV EAX, _a_
CMP EAX, _b_
JLE _label_
</code>```

Less than or b plus 1 is two extra assembler instructions.

```<code>a < b+1
</code>```

Whereas, the above would be something like:

```<code>MOV ECX, _a_
MOV EDX, _b_
ADD EDX, 1
CMP ECX, EDX
JL _label_
</code>```

To argue that one method is more readable than another is simply silly. They are both equally readable, but <= should be the standard. Anyone doing b+1 is unnecessarily adding extra tasks for the language to perform. It doesn't matter if it's Java, C#, C++ or PHP because you're telling it to perform an unnecessary addition. If you're lucky the compiler you're using will optimize this out.

Someone answered:

If you mean: i should be less than or equal to a, then write i <= a.

If you mean: i should be less than a+1, then write i < a+1.

That makes no senses at all, because the two mean exactly the same thing. The correct answer is less than or equal. The easiest to read math expression is always the simplest i <= a.

Title: Which is the better: a <= b or a < b+1

Body:
Less than or equal is 1 assembler instruction.

a <= b

On the X86 family of processors the above would be something like:

MOV EAX, _a_
CMP EAX, _b_
JLE _label_

Less than or b plus 1 is two extra assembler instructions.

a < b+1

Whereas, the above would be something like:

MOV ECX, _a_
MOV EDX, _b_
ADD EDX, 1
CMP ECX, EDX
JL _label_

To argue that one method is more readable than another is simply silly. They are both equally readable, but <= should be the standard. Anyone doing b+1 is unnecessarily adding extra tasks for the language to perform. It doesn't matter if it's Java, C#, C++ or PHP because you're telling it to perform an unnecessary addition. If you're lucky the compiler you're using will optimize this out.

Someone answered:

If you mean: i should be less than or equal to a, then write i <= a.

If you mean: i should be less than a+1, then write i < a+1.

That makes no senses at all, because the two mean exactly the same thing. The correct answer is less than or equal. The easiest to read math expression is always the simplest i <= a.


答:
PEP 435 was the proposal to add enumerations to Python. The motivation for adding enumerations:

The properties of an enumeration are useful for defining an immutable, related set of constant values that may or may not have a semantic meaning. Classic examples are days of the week (Sunday through Saturday) and school assessment grades ('A' through 'D', and 'F'). Other examples include error status values and states within a defined process.

Enumerations serve the same purpose in object-oriented code as in procedural code.


答:
My SGML is rusty, so I'm going to hope someone comes along to correct some of this but...

This line is SGML which is a super set of HTML and XML.

```<code><!doctype html>
</code>```

The <! indicates that the document should drop back to follow SGML directives, not the parent document. This is the same reason that

Title: What is the correct implementation of <meta> element in HTML5?

Body:
I've been watching a video to learn HTML. I know about HTML but I just wanted to refresh my knowledge. The author declared that he is using HTML5 because the doctype was:

```<code><!doctype html>
</code>```

but I noticed that the author used the meta element in a different style that I get used to, he used it without the the forward slash to close the element as follows:

```<code><meta charset="utf-8">
</code>```

and what I know about this is that it should be like the follwing:

```<code><meta charset="utf-8" />
</code>```

Which one of the above elements is considered HTML5? I tried to search online but it seems that every web designer has a different opinion which confused me. I like standards.

Body:
My SGML is rusty, so I'm going to hope someone comes along to correct some of this but...

This line is SGML which is a super set of HTML and XML.

<!doctype html>

The <! indicates that the document should drop back to follow SGML directives, not the parent document. This is the same reason that <!-- is the way to start a comment in XML and HTML. <! drops to SGML, and -- is the usual delimiter for comments in SGML. In the above line of code, <! doctype html> is valid SGML for declaring the doctype.

Whereas this line is a part of the standard document and needs to follow the documents rules (which are declared by the doctype, or schema dependent on the document):

<meta charset="utf-8">

In this the SGML rules no longer apply as we are looking at something that needs to conform to HTML. Now, depending on if it is HTML4, HTML5 or XHTML how the tag is closed changes.

In HTML4 many tags didn't need to be closed, and in fact in some cases were forbidden from being closed. This includes <meta>, <img> and <p> tags, where only the latter was allowed to be closed (like </p>) the other 2 should be left as is with attributes and no closing tags - because in their declaration they needed no closing tag.

However, in XHTML attempts were made to make HTML conformant to XML. A noble goal, however this meant that standalone tags line <meta> or <img> needed to be self-closing as they had no content and became <meta /> and <img /> in XHTML. However, people being overzealous started to do this in HTML4 documents as well. Technically invlaid, but most HTML parsers are very kind and eat much worse HTML, so they never really paid attention.

When HTML5 came along, everyone recognised that people were writing self-closing tags in HTML and the W3C said, "hey you know what, if everyone is doing it, let them do it legally". So, now in HTML5 you can have either <meta> or <meta />.

As for which type you should choose when writing your code. If you are outputting XHTML, you need to self-close the tag, no questions asked. Otherwise, you have options:

Arguments against self-closing:

Over thousands of page views the additional space and slash add up. Google does some heinous things to make readable HTML that saves bytes - for a while they omitted </body> and </head> closing tags.

Arguments for self-closing:

Closing tags and making your HTML close to XML, makes it easier for XML based parsers to read your content, which may make searching or scraping content easier if you are using XML based technologies like XPath.

The choice is really up to you, but regardless of which approach you take, consistency is the key.


问:
Optimization of time-varying parameters
I need to find an optimal set of "n" parameter values that minimize an objective function (a 2-hr simulation of a system). I have looked at genetic algorithm and simulated annealing methods, but was wondering if there are any better algorithms and guidance on their merits and limitations.

With the above optimization methods I can find the optimal parameter values that hold true for the entire simulation duration. Incase, I want to find the optimal "time varying" parameter values (parameter values change with time during the 2-hr simulation), are there any methods/ideas other than making each time varying parameter value a variable to optimize? Any thoughts?

答:
Some thoughts:

There is something called local regression ("loess" for short, pronounced Low-Ess). Whether that's helpful is for you to decide.

I work on products for doing non-linear mixed effects modeling (NLME) in the context of pharmacometrics. So, for example, each subject can have a parameter called V, for volume of distribution (basically blood plasma volume) that affects the observed concentration after a dose of drug. In some models, V may change over time. If so, we try to find a time-varying input datum called a "covariate", such as body weight W. Then we might make a model where V = V0 + k W, where V0 is some kind of base volume, and k determines how much weight affects volume. So we're estimating non-time-varying parameters V0 and k, even though V is time-varying.

Title: Optimization of time-varying parameters


问:
Handling multiple clients using single application
We are developing an ERP web application using Vaadin framework where each of the potential client companies will have their own data and file storage. Current implementation only allows having one client company per application instance, what consequently requires separate database schema and file storage.
Some of the clients may want specific customizations based on their needs.

Having few clients doesn't cause much trouble, but if number of clients would grow, then maintaining dozens of application instances will be a real challenge.

We are reaching that point where we have to choose one these options:

Improve our architecture to allow all client companies manage their data on a single application instance and restrict personal customizations to the application;

Stick with the current implementation and just keep increasing number of running application instances on the server.

Which of these options is considered better practice and would make the system easier to maintain? Is there a different solution for this kind of situation?

Edit:
Application is currently in development stage.
The server with all the potential application instances will be run by ourselves. Each instance will be deployed in a WAR package via Apache Tomcat server.

答:
Multitenancy is a hard problem. Very hard. I've seen a lot of companies do it, very few of them having done it well.

To cite just one of the many examples of where multi-tenant systems can fall apart, consider what will happen when one customers wants a data warehouse or ad-hoc reporting database. Can you spin one off relatively easily, or do you have to go through an immensely painful data scrubbing process that takes forever to run, has to drop a bunch of keys and constraints, and often loses data that is technically supposed to be shared?

I've seen the latter scenario happen at least twice. It's not uncommon.

Multi-tenant systems really have to be written as multi-tenant systems from the ground up. If you try to convert a traditional multi-instance farm to a multi-tenant system, you will screw it up for several iterations. And if you choose to rewrite... well, best of luck.

There are a lot of advantages to multi-tenant systems, but contrary to (apparently) popular belief and/or intuition, productivity is not one of them, at least not until such time as you are maintaining dozens or even hundreds of separate instances. It adds a huge amount of complexity, related both to look and feel and to the business logic itself. You'll probably need some kind of rules or workflow engine. And your uptime and support/call-centre performance will suddenly become a lot more sensitive, because any failure you experience will affect all your clients, not just one.

You will also definitely have to reign in the customizations if every customer is on a shared system. You will eventually run into a situation where two different customers have mutually exclusive requirements and will have to choose a victim. If your organization, like so many organizations, has trouble saying "no" to paying customers, this will bite you, hard.

Most of the cost savings that multi-tenancy has historically provided on hardware can also be obtained today with virtualization. With vSphere or similar products it's almost trivially easy and quick to spin up new instances, even if installation is normally very complicated.

What you don't get with virtualization is the simplified deployment (new releases) and the ability to do data mining. Question is, would either of these benefit you right now?

Rolling out 1 update instead of 10 updates might be easier... if you've got really tight QA and are extremely confident in the stability of the product. If not, then that 1 huge update is far riskier than the 10 small updates. Only you (and your company) can decide which applies to you. And as for analytics - if you're not big on analytics now, or privacy laws/regulations prevent you from doing that kind of data mining, then don't assume that a shared database is suddenly going to start benefiting you in the distant future.

Just to be clear, I'm not against multi-tenancy, but you're hardly the first person to ask the question or the first company to go down that path. Don't assume that it's going to be easy to consolidate, and definitely don't assume that it's going to be easier to maintain afterward. It's generally a lot harder; you should only go with that solution if its specific benefits are particularly important to you.

For vendors without a huge number of clients, it's probably better to invest your time in test and release automation. If you've got a full suite of regression tests running every night and can do a promotion in 10-15 minutes (generally parallelizable), the number of instances tends not to matter that much. There's a limit, yes, but... you'll know when you're getting near it.


答:
Maybe you should think about deploying one VM per customer.

Have a few "standard" VMs set up for the most common customer profiles so you can quickly deploy new customers -- deply the VM, configure the IP address and user passwords and its ready for use.

Once deployed the VM instance can be customized to you hearts content.

Cisco, VMWARE et. al. have sophisticated tool sets for handling multiple VMs.

The only gotcha is you need to be very structured in how you handle customization, you need to ensure that can save and re-apply any custom code whenever a VM is configured or upgraded.

Title: Handling multiple clients using single application

Body:
We are developing an ERP web application using Vaadin framework where each of the potential client companies will have their own data and file storage. Current implementation only allows having one client company per application instance, what consequently requires separate database schema and file storage.
Some of the clients may want specific customizations based on their needs.

Having few clients doesn't cause much trouble, but if number of clients would grow, then maintaining dozens of application instances will be a real challenge.

We are reaching that point where we have to choose one these options:

Improve our architecture to allow all client companies manage their data on a single application instance and restrict personal customizations to the application;

Stick with the current implementation and just keep increasing number of running application instances on the server.

Which of these options is considered better practice and would make the system easier to maintain? Is there a different solution for this kind of situation?

Edit:
Application is currently in development stage.
The server with all the potential application instances will be run by ourselves. Each instance will be deployed in a WAR package via Apache Tomcat server.


问:
Do delegates defy OOP
I'm trying to understand OOP so I can write better OOP code and one thing which keeps coming up is this concept of a delegate (using .NET). I could have an object, which is totally self contained (encapsulated); it knows nothing of the outside world... but then I attach a delegate to it.

In my head, this is still quite well separated as the delegate only knows what to reference, but this by itself means it has to know about something else outside it's world! That a method exists within another class!

Have I got myself it total muddle here, or is this a grey area, or is this actually down to interpretation (and if so, sorry as that will be off topic I'm sure). My question is, do delegates defy/muddy the OOP pattern?

答:
No. Delegate complements OOP.

Because OOP has no notion of having function/method as data to be passed as event handler value, and for callbacks. Also having method as data therefore can be included as a parameter in the method, gaves us expressiveness and flexibility.

The necessity becomes more if you get introduced to code asynchronously, since you need to know which function/method as a callback to do something after your code returns continuations.

Therefore, please don't limit yourself to the definition of OOP as is. Those established OOP languages such as C#, VB, F#, even C++ has supports for delegates, otherwise these languages will lose competitiveness if there are no delegate supports at all.

Of course if you're implementing delegates in a bad way such as having bad smell in your code, the net result is the same as implementing OOP badly.

Title: Do delegates defy OOP


答:
Managing database access through a service account is simpler. It segregates awareness of user rights from the database, and that has the usual benefits of such segregation, like reducing management and failure points. The less of those that one has, the easier it is to put together administration procedures and to diagnose problems.

Depending on your application, it may also enable better connection pooling and therefore better performance.

Title: Best practice in application design / SQL authentication

Body:
I am currently involved in the implementation/design of an existing application for a large scale customer. The application has a similar model as e.g. vCenter Server whereby a number of components store information in and extract information and workflows form a central database. The environment is managed from a console application which uses a windows service to connect to the database.

Due to security considerations SQL Authentication is not an option, but the application does support Windows Authentication. However when using windows authentication it passes the credentials of the user who is using the management console application on to the database in stead of using the service account under which the service runs.

This results in the situation where the security roles as they are defined within the application (AD users/groups mapped to certain permissions) requires these AD objects to also have a SQL Server login and certain permissions on the database (db-writer for certain tables, depending on the specific permissions in the app).

Apart from the additional administration, this also creates a security risk IMO because the whole point of the application security roles in this specific application is to allow users access to only a part of a certain table (e.g. a subset of the objects). But since they now have a SQL login and db_writer on that entire table they could bypass the app and with a direct connection to the database they could read/alter records they would not be allowed to view/manipulate through the application.

This risk could then (partly) be mitigated by restricting access to the database on a network level, or possibly use triggers to check the calling hostname and program name, but as far as I know that is not completely safe.

The only benefit as is presented to me is there is now a full audit trail available in SQL server on exactly who did what. But this is already implemented in the application as well so it seems kind of moot to me.

I have been frantically searching for any info on this and what would be the best practice. I can only find ASP / Web based stuff but nothing regarding this type of application.

Is it really the best way to go with passing through authentication to SQL server or should the app handle authorization and send all database requests using the service account?

P.S.: This is my first question on stackexchange, if I posted on the wrong sub-site or you find my question inappropriate, please just let me know.


问:
What is the gain from 64-bit architecture?
I played with 8-bit machines (C64), I used 16-bit machines (Win 3.1), I enjoyed flat 32-bit address space (Linux).

Every time as a user (which was also means being a developer for fun or profit) I felt the need for more bits and welcomed the next wider bit architecture. Accessing to bigger memory space got easier, graphics got better and sound was a bliss after 8-bit.

However when marketing drums started to kick in for 64-bit some years ago I thought, "ok, this is Internet age, they can use this kind of power to do more calculations easier and commodity hardware manufacturers want to spread their portfolio for this kind of market".

Professionally I became a "system programmer" working for mobile devices which some what means being an "embedded programmer" as well. Working mostly on 32-bit from the start ARM architecture based products, it was a while I forgot about different architectures other than being 32-bit.

Also when ARM announced a new 64-bit architecture towards end of 2011, I read it as ARM wants to go into server market, increasing their portfolio. Which makes sense.

Now with new iPhone 5S claiming to be the first 64-bit processor ever used on a smartphone, thoughts became a little bit unsettled in my head again. Mobile devices, being the ultimate personal devices are becoming 64-bit.

So I wonder, is there something I'm missing? What does being 64-bit offers to the users including programmers?

答:
The fundamental advantage is larger register size ( and ALU capability ).

Basially, I can now multiply 10 trillion million billion by 7 in one step.
 Before with 32 bit I had to split the operands into two pieces that could fit in 32 bit registers and use off die memory to store intermediate results.

This doesn't seem like a big deal, until you look at how many time code written for a 32 bit processor has to split a math operand or split a four word hash key ( or high precision floating point ) or something into two pieces to sort or branch on it.


问:
Is there any situation in which it would be appropriate to use unless... else?
This construction is considered wrong

```<code>unless
  #..
else
  #..
end
</code>```

This is for the general reason of double-negative confusions.  It translates to:

```<code>if not
  #..
if not not
  #..
end
</code>```

We all agree this is confusing.

Is there any situation (include semantic) that the unless..else construction would be more appropriate?

答:
You don't want "unless" because it easily leads to confusion because an if condition with a built in negative would be just bad design. Also because it's easy to just use an "if".

You would get constructs like:

```<code>unless !(x=3) {

unless(item.isnotred){
</code>```

which you have to read twice, where an easy:

```<code>if (x=3)

if (item.isred){
</code>```

is very clear.

Unless operator leads to double negatives which should be avoided.

Body:
You don't want "unless" because it easily leads to confusion because an if condition with a built in negative would be just bad design. Also because it's easy to just use an "if".

You would get constructs like:

unless !(x=3) {

unless(item.isnotred){

which you have to read twice, where an easy:

if (x=3)

if (item.isred){

is very clear.

Unless operator leads to double negatives which should be avoided.


问:
Path to learning compiler design
I'm not sure if this is an acceptable question, but compiler-os-design-where-to-start was, so I figured that I'd take a shot at it.

I have taken no formal Computer Science classes.  I have programmed in Python and attempted C# without success.  My technical vocabulary is expansive, yet scattered over a very wide range of computer science topics.

I have a very long way to go before I can get to a level where I could reasonably read a book about compiler design/theory.  I am asking what steps I need to take before attempting compiler design.  I have some examples here already:

Computer architecture

Binary

How booting/kernels/OSes work

Imperative vs. Comparative language design

"Grammars"

At least these are some examples of what I've seen.

Edit: I can't for the life of me see how this problem is unclear.  I quite clearly bolded what I was asking.  I was expecting it to be marked as biased, vague/broad, or too generalized, but certainly not unclear.  Don't be afraid to say it's unconstructive (just make sure whatever it is classified under is accurate).

答:
Compilers are not some mythical creatures, even though some people might like you to think that.

A compiler is a program like any other program. It takes some input, tries to make sense of it, and generates some output. Have you ever written a program which reads a text file in some format and outputs some HTML based on that text? Well, congratulations: you already have written a compiler. A very simple one, I admit, but it is a compiler.

You approach it like any other program: try, fail, learn, repeat.

Some resources to help you fail less and learn more :-)

Let's Build a Compiler, by Jack Crenshaw

A Nanopass Framework for Compiler Education, by Dipanwita Sarkar, Oscar Waddell, and R. Kent Dybvig

Title: Path to learning compiler design


答:
As you said, enumerations tend to give rise to case discrimination … after all, how else are you going to make sense of the different values of the enumeration?

But in OOP, we already have a perfectly good way of doing case discrimination: polymorphic message dispatch. That's all you need. You don't need case or switch or even if or for or while. Smalltalk doesn't have any of those, it doesn't have any conditionals, it doesn't have any loops, it doesn't have any case discrimination. Only polymorphic message dispatch. And it works just fine that way.

So, where you would do something like this in a language without polymorphic message dispatch:

```<code>enum Weekday {
  Monday,
  Tuesday,
  Wednesday,
  Thursday,
  Friday,
  Saturday,
  Sunday
}

def weekdayToString(day: Weekday) = match day {
  case Weekday.Monday    => "Monday"
  case Weekday.Tuesday   => "Tuesday"
  case Weekday.Wednesday => "Wednesday"
  case Weekday.Thursday  => "Thursday"
  case Weekday.Friday    => "Friday"
  case Weekday.Saturday  => "Saturday"
  case Weekday.Sunday    => "Sunday"
}

def printWeekday(day: Weekday) = println(weekdayToString(day))

printWeekday(Weekday.Wednesday)
// Wednesday
</code>```

In a language with polymorphic message dispatch, you would do it like this:

```<code>sealed trait Weekday
object Monday    extends Weekday { override def toString() = "Monday"    }
object Tuesday   extends Weekday { override def toString() = "Tuesday"   }
object Wednesday extends Weekday { override def toString() = "Wednesday" }
object Thursday  extends Weekday { override def toString() = "Thursday"  }
object Friday    extends Weekday { override def toString() = "Friday"    }
object Saturday  extends Weekday { override def toString() = "Saturday"  }
object Sunday    extends Weekday { override def toString() = "Sunday"    }

def printWeekday(day: Weekday) = println(day)

printWeekday(Wednesday)
// Wednesday
</code>```

(That is actually runnable Scala code.)

In other words: you can always replace an enumeration with case discrimination with an inheritance hierarchy with polymorphism.

Interestingly, Scala actually does have enumerations, but there are efforts for removing them from the language. They just don't add any significant expressive power to a language which already has objects.

Body:
As you said, enumerations tend to give rise to case discrimination … after all, how else are you going to make sense of the different values of the enumeration?

But in OOP, we already have a perfectly good way of doing case discrimination: polymorphic message dispatch. That's all you need. You don't need case or switch or even if or for or while. Smalltalk doesn't have any of those, it doesn't have any conditionals, it doesn't have any loops, it doesn't have any case discrimination. Only polymorphic message dispatch. And it works just fine that way.

So, where you would do something like this in a language without polymorphic message dispatch:

enum Weekday {
  Monday,
  Tuesday,
  Wednesday,
  Thursday,
  Friday,
  Saturday,
  Sunday
}

def weekdayToString(day: Weekday) = match day {
  case Weekday.Monday    => "Monday"
  case Weekday.Tuesday   => "Tuesday"
  case Weekday.Wednesday => "Wednesday"
  case Weekday.Thursday  => "Thursday"
  case Weekday.Friday    => "Friday"
  case Weekday.Saturday  => "Saturday"
  case Weekday.Sunday    => "Sunday"
}

def printWeekday(day: Weekday) = println(weekdayToString(day))

printWeekday(Weekday.Wednesday)
// Wednesday

In a language with polymorphic message dispatch, you would do it like this:

sealed trait Weekday
object Monday    extends Weekday { override def toString() = "Monday"    }
object Tuesday   extends Weekday { override def toString() = "Tuesday"   }
object Wednesday extends Weekday { override def toString() = "Wednesday" }
object Thursday  extends Weekday { override def toString() = "Thursday"  }
object Friday    extends Weekday { override def toString() = "Friday"    }
object Saturday  extends Weekday { override def toString() = "Saturday"  }
object Sunday    extends Weekday { override def toString() = "Sunday"    }

def printWeekday(day: Weekday) = println(day)

printWeekday(Wednesday)
// Wednesday

(That is actually runnable Scala code.)

In other words: you can always replace an enumeration with case discrimination with an inheritance hierarchy with polymorphism.

Interestingly, Scala actually does have enumerations, but there are efforts for removing them from the language. They just don't add any significant expressive power to a language which already has objects.


问:
How to get Object Oriented Programming Concepts?
What is the best way or best resources or tutorials to learn Object Oriented Programming?

For instance, when I begin a program with Java and all my code goes into just one class and I can't estimate when I need to create new classes and operate on these classes together.

答:
A class must aim to do one thing and do it well. Nothing else.

There's more to it than that, but that's the main thing. If you go by that you can't go wrong.
If your class does too much, it's time to break it apart into smaller pieces.

This is known as the Single Responsibility Principle (emphasis mine):

In object-oriented programming, the single responsibility principle states that every class should have a single responsibility, and that responsibility should be entirely encapsulated by the class. All its services should be narrowly aligned with that responsibility.

Note that I am just answering your example. For the rest, your question is too broad. Your best bet to "get" OOP will be to indeed practice OOP. Just:

Read a few books.

Do some projects to break your teeth on these concepts a few times.

Don't try to memorize all these fancy names (including the SRP above).

Get your code bashed and reviewed.


答:
It starts at the design phase, before you write any code.  Think about what your program is modelling.  If its an e-commerce website you might think about Customer, order, product and so on.  These nouns become your first objects.

Then you think about what processes need to occur. As an example, when the website takes a new order, there will need to be a point where you take payment for the order.  You may define an object as Payment, and this object represents the payment details, and the status of the payment. Now different payment types need processing differently. So you could define a common interface IPaymentProcessor and then create payment processor objects that each only process particular types of payment. e.g PayPalPaymentProcessor and VisaPaymentProcessor.

At this stage, you are starting to write object oriented code...

Title: How to get Object Oriented Programming Concepts?

Body:
What is the best way or best resources or tutorials to learn Object Oriented Programming?

For instance, when I begin a program with Java and all my code goes into just one class and I can't estimate when I need to create new classes and operate on these classes together.


答:
. . . are there times when using an enumeration is a good decision?

I used an enum (via C#) to define a fixed, ordered set of "tasks". The underlying integer values defined order. A wrapping class used the enum for instance equality. A collection class used the enum for sorting and enforcing uniqueness w/in the collection. These classes replaced code that was hopelessly broken functionally and conceptually.

That enum was effectively a "core" data structure at the heart of higher-functioning composite data structures. In capturing essence of the domain objects at the core the composites were clean and the business functionality was delightfully concise.


答:
Nicklaus Wirth's text on compiler construction is arguably one of the two most approachable texts on the subject.  The other is Jack Crenshaw's series of articles, cited by the other guy.

If you want to go the Dragon Book route, there's no easy approach, but you can start by working your way through Course 6 at ocw.mit.edu.  You'll have to pick and choose the Computer Science classes.

Title: Path to learning compiler design

Body:
I'm not sure if this is an acceptable question, but compiler-os-design-where-to-start was, so I figured that I'd take a shot at it.

I have taken no formal Computer Science classes.  I have programmed in Python and attempted C# without success.  My technical vocabulary is expansive, yet scattered over a very wide range of computer science topics.

I have a very long way to go before I can get to a level where I could reasonably read a book about compiler design/theory.  I am asking what steps I need to take before attempting compiler design.  I have some examples here already:

Computer architecture

Binary

How booting/kernels/OSes work

Imperative vs. Comparative language design

"Grammars"

At least these are some examples of what I've seen.

Edit: I can't for the life of me see how this problem is unclear.  I quite clearly bolded what I was asking.  I was expecting it to be marked as biased, vague/broad, or too generalized, but certainly not unclear.  Don't be afraid to say it's unconstructive (just make sure whatever it is classified under is accurate).