答:
For my hobby app, I'm using Java with the object validation framework known as JSR-303. Here's the link to my answer to a similar question on SO, but specific to that setup.

Overview:

When the Submit button is clicked, I gather form data and submit it via AJAX GET to my server-side validator.

Validation happens behind the scenes, and the server pulls any error messages out of the validation response, packages them up, and sends them back to the client as JSON.

When an error validation response shows up at the client, I apply and/or clear error styling from the appropriate form fields.

When a success validation response shows up at the client, I do the normal form submit. At some point I'll change it to resubmit as AJAX.

I need to update the code at the linked answer, but that's the gist of it.

Title: Making simple forms in web applications

Body:
How do you work with forms in your web applications?

I am not talking about RESTful applications, I don't want to build heavy front-end using frameworks like Backbone.

For example, I need to add "contact us" form. I need to check data which was filled by user and tell him that his data was sent.
Requirements:

I want to use AJAX.

I want to validate form on back-end side and don't want to duplicate the same code on front-end side.

I have my own solution, but it doesn't satisfy me. I make an AJAX request with serialized data on form submit and get response. The next is checking "Content-type" header.

html -> It means that errors with filling form are exists and response html is form with error labels. -> I will replace my form with response html.

json and response.error_code == 0 -> It means that form was successfully submited. -> I will show user notification about success.

json and response.error_code != 0 -> Something was broken on back-end (like connection with database).

other - I display the following message :

We have been notified and have started to work with that problem. Please, try it later.

The problem of that way is that I can't use it with forms that upload file.

What is your practise? What libraries and principles do you use?


问:
Does software rot refer primarily to performance, or to messy code?
Wikipedia's definition of software rot focuses on the performance of the software. This is a different usage than I am used to; I had thought of it much more in terms of the cleanliness and design of the code—in terms of the code's having all the standard quality characteristics: readability, maintainability, etc. Now, performance is likely to go down when the code becomes unreadable, because no one knows what is going on. But does the term software rot have special reference to performance? or am I right in thinking it refers to the cleanliness of the code? or is this perhaps a case of multiple senses of the term being in common usage—from the user's perspective, it has do with performance; but for the software craftsman, it has to do more specifically with how the code reads?

答:
Software doesn't actually go bad, get stale, wear out or "rot" in the traditional sense.

If the environment in which software operates doesn't change, the software will essentially last forever.  This is why I get so peeved when someone asks if some library is "dead" because the author hasn't made an update to it in the last 5 minutes (exaggerating only slightly for effect).

But the environment usually does change; operating systems are patched and updated, computers get replaced with more powerful ones, and new programs get installed (like the latest version of a client like Internet Explorer, device drivers or other libraries), on which the software may depend.  So the software must be updated to take into account those changes.

There are software systems that have been running continuously and reliably for literally decades without being significantly updated or maintained.  COBOL software running on mainframes that handle bank transactions come to mind (although they all had to be modified in 1999 to handle Y2K).

Wikipedia's emphasis on performance seems to be missing the point; many software applications actually get a performance boost when they get installed in a newer environment.  The Wikipedia article actually seems more concerned with software bloat.

ContentLicense: CC BY-SA 3.0


问:
Making simple forms in web applications
How do you work with forms in your web applications?

I am not talking about RESTful applications, I don't want to build heavy front-end using frameworks like Backbone.

For example, I need to add "contact us" form. I need to check data which was filled by user and tell him that his data was sent.
Requirements:

I want to use AJAX.

I want to validate form on back-end side and don't want to duplicate the same code on front-end side.

I have my own solution, but it doesn't satisfy me. I make an AJAX request with serialized data on form submit and get response. The next is checking "Content-type" header.

html -> It means that errors with filling form are exists and response html is form with error labels. -> I will replace my form with response html.

json and response.error_code == 0 -> It means that form was successfully submited. -> I will show user notification about success.

json and response.error_code != 0 -> Something was broken on back-end (like connection with database).

other - I display the following message :

We have been notified and have started to work with that problem. Please, try it later.

The problem of that way is that I can't use it with forms that upload file.

What is your practise? What libraries and principles do you use?

答:
I never tried it but i heard of haxe which allows you to write code that is generated to js and works on the server http://haxe.org/doc/start/js but I do assume its not very good because i never heard of sites being built with haxe

It generates to php java and other languages http://haxe.org/doc/start

Title: Making simple forms in web applications


问:
What does the python Codecs module do?
I just read through the documentation on the Codecs module, but I guess my knowledge/experience of comp sci doesn't run deep enough yet for me to comprehend it.

It's for dealing with encoding/decoding, especially Unicode, and while to many of you that's a complete and perfect explanation, to me that's really vague. I don't really understand what it means at all. Text is text is text in a .txt file? Or so this amateur thought.

Can anyone explain?

答:
Have a look at Dive Into Python 3 by Mark Pilgrim, Chapter 4. Strings. It is for Python 3 -- the chapter explains what is the difference between the sequence of bytes and abstract strings (text).

The codecs documentation is about the same things. But the explanation in the chapter is more understandable for newcomers.

Title: What does the python Codecs module do?


问:
How to find out if a company has insane policies
When interviewing for a job, is there a delicate yet accurate way to find out if they have insane policies, like "no open source", or "no installing software without permission", "not upgrading software until it's about to lose support", or "no visiting blogs"?</p>

答:
Those are questions you can bring up at the end of the interview when the interviewer normally asks "Do you have any questions for me"

Just try and phrase them in such a way so the question links to the job you are applying for. For example, I might phrase these questions such as:

Does the company have an opinion about using Open Source software?

What is the company policy about installing custom software? For example, I use XXX which helps me speed up development.

Do you use a web content filter? I ask because the last place I worked for had one that severely limited my research capabilities.

ContentLicense: CC BY-SA 2.5


问:
Responding to end users about bugs they found
I have an issue tracking system, but sometimes users report bugs directly to me in an email.

If I'm responding to a bug report in an email, what's a good etiquette to use? Do I thank them for reporting the bug? Do I apologize for it ? Is there a good template anywhere?

答:
This depends greatly on whether you mean an internal user, an external user or paying customer.

You can't point some people at issue trackers. I think the first two answers are good and a combination of elements is set by the user and how they are related to what you do.

Thank them for bringing it to your attention

build as full a picture as possible about the bug (if it's via email forms, you can grab their environment vars through the browser - which helps)

Assure them that the bug/issues will be attended to by the team ("we're always looking to improve our user experience"...)

NOTE: If they are a paying customer, then priority is likely to be high if money/transactions are involved.

Add it to an internal tracker (if you have one)

Assign it a priority based on the severity/importance

Once its been through testing, QA and released, contact the user who found it and let them know its fixed and thank them again

This is generalised, but liaison with users of any sort is really important.

Hope this helps.


答:
I'd ask if the internet was considered a resource, i.e. things like Stack Overflow, or if there was a limited internet usage policy.

I'd visit https://www.glassdoor.com to find out all I could about a company.

I'd ask engineers about their normal day.

Title: How to find out if a company has insane policies

Body: When interviewing for a job, is there a delicate yet accurate way to find out if they have insane policies, like "no open source", or "no installing software without permission", "not upgrading software until it's about to lose support", or "no visiting blogs"?</p>


问:
What types of processes have to be reflected in flowchart?
In visual programming, there are many events which support our application tasks. So, along with user defined processes, should these also be in flowchart or not?

What about the constructors of classes, are they supposed to be shown in flowchart or not?

答:
Not to intentionally be a contrary, but in answer to the question:

"What types of processes have to be reflected in flowchart?"

I think the answer is none of them.

Flow charts have been around a long time.  For developers, they are time consuming to produce, particularly in the quantity that would be needed for a commercial scope project.  They also have the disadvantage of going stale pretty fast once developers start coding to them and integrating logic discovered during implementation and test.

In casual conversation with Dr. Bill Curtis, who was one of the authors of the SEI CMM 1.1 and a person with some background in software process and psychology (a PhD), he said to me and others that our diagrams depend on people being high-spatial to understand them, but people who were high-spatial could pretty easily form a mental picture from text representations of software like pseudo code.

Most of the object oriented methods advocate leaving behind flow charts and also data flow diagram as artifacts of structured programming and even pre-structured programming.  More useful are techniques like use cases annotated with alternative flows.  Use cases tend to start with a nominal flow that may describe some conditions, but not much branching of the control flow.  Branching is covered in alternative cases, and typically references the nominal flow for brevity, accentuating only the differences.  Another good reason to consider use cases instead of flow charts is that they can easily include as much text as is needed for clarity, although all but the shortest text can cause problems with gracefully sliding text into flow charts, and combined with routing and other manual manipulations, can eat up a lot of time, sometimes with good benefit, sometimes without.


问:
Test case as a function or test case as a class
I am having a design problem in test automation:-

Requirements - Need to test different servers (using unix console and not GUI) through automation framework. Tests which I'm going to run - Unit, System, Integration

Question: While designing a test case, I am thinking that a Test Case should be a part of a test suite (test suite is a class), just as we have in Python's pyunit framework. But, should we keep test cases as functions for a scalable automation framework or should be keep test cases as separate classes(each having their own setup, run and teardown methods) ?
From automation perspective, Is the idea of having a test case as a class more scalable, maintainable or as a function?

答:
In the past, a test case usually referred to a function / method. However, in our days, a Test Case usually refers to a "Test", meaning a class containing a set of methods which are strongly related to each-other from a testing point of view.

Methods in these Test Case classes are called Test Methods.

Considering this, the inclusion would be. Test Method (testing a specific single thing - state or behavior) is part of a Test Case (which refers probably to a functionality or submodule) which in turn is part of a Test Suite (which refers to a bunch of test cases and can be organized as you wish).

For more on these structures and test organization in general I recommend you xUnit Test Patterns: Refactoring Test Code by Gerard Meszaros


答:
The following is my opinion:

Pros of writing tests as functions:

If you need any pre-requisites for that test case, just call another function which provides the pre-requisites. Do the same thing for teardown steps

Looks simple for a new person in the team. Easy to undertstand what is happening by looking into tests as functions

Cons of writing tests as functions:

Not maintainable - Because if there are huge number of tests where
same kind of pre-requisites are required, the test case author has to
maintain calling each pre-requisite function in the test case. Same
for each teardown inside the test case

If there are so many calls to such a pre-requisite function inside many test cases, and if anything changes in the product functionality etc, you have to manually make efforts in many places again.

Pros of writing test cases as classes:

Setup, run and teardown are clearly defined. the test pre-requisites are easily understood

If there is Test 1 which is does something and the result of Test 1 is used as a setup pre-requisite in Test 2 and 3, its easy to just inherit from Test 1, and call its setup, run a teardown methods first, and then, continue your tests. This helps make the tests independent of each other. Here, you dont need to make efforts to maintain the actual calling of your code. It will be done implicitly because of inheritance.

Sometimes, if the setup method of Test 1 and run method of Test 2 might become the pre-requisites of another Test 3. In that case, just inherit from both of Test 1 and Test 2 classes and in the Test 3's setup method, call the setup of Test 1 and run of Test 2. Again you dont need to need to maintain the calling of the actual code, because you are calling the setup and run methods, which are tried and tested from the framework perspective.

Cons of writing test case as classes:

When the number of tests increase, you cant look into a particular test and say what it does, because it may have inherited so much levels that you cant back track. But, there is a solution around it - Write doc strings in each setup, run, teardown method of each test case. And, write a custom wrapper to generate doc strings for each test case. While/After inheriting, you should provide an option to add/Remove the docstring of a particular function (setup, run, teardown) to the inherited function. This way, you can just run that wrapper and get information about a test case from its doc-strings

Title: Test case as a function or test case as a class

Body:
I am having a design problem in test automation:-

Requirements - Need to test different servers (using unix console and not GUI) through automation framework. Tests which I'm going to run - Unit, System, Integration

Question: While designing a test case, I am thinking that a Test Case should be a part of a test suite (test suite is a class), just as we have in Python's pyunit framework. But, should we keep test cases as functions for a scalable automation framework or should be keep test cases as separate classes(each having their own setup, run and teardown methods) ?
From automation perspective, Is the idea of having a test case as a class more scalable, maintainable or as a function?


答:
I prefer Testcase as a class because

In Untitests you usally have several tests with a similar context that would logicaly grouped together by a class.

In Integration and System-Tests you usally have a kind of global variables that are updated/verified in the test-steps. If these global variables are not members of a class you are not able to run several tests concurrently (for performance or stresstest) because the tests would influence each other.

Actually i dont see any benefit of a non-class-testmethod.


问:
What is the correct pattern to use in this case?
I'm sure this scenario has arisen before, and I want to know what experience has taught to be the best solution.

I have a number of classes that are all of a kind.  Say all the objects are "Content".  They may be "Article", or "Book" for example.

The reason I want the "Content" abstraction is because I want to define a number of behaviours for all "Content" objects and not have to build a new DB Table and 10 classes of essentially the same code for each type of "Content".  For example, to attach a "Tag" or a "Premise" to a content object would be much nicer if, say, I just had two columns one for ContentID and one for TagID.

A solution I've played around with is to have a Content table with a unique ID, and then to have foreign key references on all the other tables (Book, Article, etc).  This has actually proven quite solid, but I'm just not sure about it.

Do you know how to call this described pattern?

答:
If you know in advance the entire set of possible types of content you could use table-per-hierarchy and stick all of the books, articles etc. sub-classes of Content into one table,
If, on the other hand, you may (or already know you will)  need new subclasses of  Content later on I'd use table-per-subclass (like you are thinking about)

So, the question in my opinion is to ask: Is my set of Content subclasses complete or should it be easily extendable later?


答:
I have been running into something similar, with a base table of Persons, a useful abstraction, and then other tables depending on whether they are Contractor, Client, etc.

For the table design, if the "sub table" (in your case, Book, Article) cannot exist without being Content, then I'd go with your design, and use the Content_ID as the key for Book and Article as well.

Since I use PHP, I have a class that handles Content, then a class that extends that to handle Books/Articles.

If you are using the database, I'd recommend a VIEW which SELECTS and JOINs the Content-Book tables, and another with does Content-Articles for ease of use.

Title: What is the correct pattern to use in this case?

Body:
I'm sure this scenario has arisen before, and I want to know what experience has taught to be the best solution.

I have a number of classes that are all of a kind.  Say all the objects are "Content".  They may be "Article", or "Book" for example.

The reason I want the "Content" abstraction is because I want to define a number of behaviours for all "Content" objects and not have to build a new DB Table and 10 classes of essentially the same code for each type of "Content".  For example, to attach a "Tag" or a "Premise" to a content object would be much nicer if, say, I just had two columns one for ContentID and one for TagID.

A solution I've played around with is to have a Content table with a unique ID, and then to have foreign key references on all the other tables (Book, Article, etc).  This has actually proven quite solid, but I'm just not sure about it.

Do you know how to call this described pattern?


答:
You can map inheritance to database tables in the following ways,

Map the entire class hierarchy to a single table: All attributes of the classes are stored in one table. This is a good strategy for simple and/or shallow class hierarchies where there is little or no overlap between the types within the hierarchy.

Map each concrete class to its own table: A table is created for each concrete class, each table including both the attributes implemented by the class and its inherited attributes. This is a good strategy when changing types and/or overlap between types is rare.

Map each class to its own table: Create one table per class, with one column per business attributes and any necessary identification information (as well as other columns required for concurrency control and versioning). This is a good strategy when there is significant overlap between types or when changing types is common..

As said, none of these mapping strategies are ideal for all situations. Experts recommend to start with one table per hierarchy at first, then if needed refactor schema accordingly.

Do you know how to call this described pattern?

Catalog of Patterns of Enterprise Application Architecture calls this Inheritance Mappers.


问:
Is this usage of extend relationship in a use case diagram correct?
On this picture:

Does updating grades extend a feature that shows grades? I am not sure if the notation is correct, so I am hoping you guys will know it.

答:
In UML modeling, you can use an extend relationship to specify that one use case (extension) extends the behavior of another use case (base).

Suppose we sell products. Customers can set requirements to a degree like setting size or color. So, such requirements add extra flow to the use case. In such scenarios, extend relationship can be used to pull the alternative flows into a new use case.

Does updating grades extend a feature that shows grades? I am not sure if the notation is correct, so I am hoping you guys will know it.

Updating grades do not extend show grades.


答:
Get a chance to meet their existing developers.  What the HR person or manager thinks the policy is, and how it actually works on the ground, are often different.  These are all questions I'd ask someone with a similar job description to my own, not the boss.

Bosses and HR types, on the other hand, generally understand that corporate culture is important, and that allowing a prospective hire a few hours contact with their team to make sure it feels like the right fit reduces risk for you and for them.


问:
Is the use of "utf8=✓" preferable to "utf8=true"?
I have recently seen a few URIs containing the query parameter "utf8=✓". My first impression (after thinking "mmm, looks cool") was that this could be used to detect a broken character encoding.

So, is this a better way to resolve potential problems with character encoding, or is it just a developer having fun with a hack?

答:
By default, older versions of IE (<=8) will submit form data in Latin-1 encoding if possible. By including a character that can't be expressed in Latin-1, IE is forced to use UTF-8 encoding for its form submissions, which simplifies various backend processes, for example database persistence.

If the parameter was instead utf8=true then this wouldn't trigger the UTF-8 encoding in these browsers.


答:
Does updating grades extend a feature that shows grades? I am not sure if the notation is correct, so I am hoping you guys will know it.

No, it does not extend. Updating grades is a standard CRUD operation.

You may think of extension use cases as an Interface with the behaviors of the context that it presents. Programming to the interface reduces dependency on implementation specifics and makes code more reusable and flexible to changes.

Title: Is this usage of extend relationship in a use case diagram correct?

Body:
On this picture:

Does updating grades extend a feature that shows grades? I am not sure if the notation is correct, so I am hoping you guys will know it.


答:
Some companies have generally awful cultures and that often extends to having awful environments for software development. I think there are three issues here

What is the companies culture?

How does that culture extend to software development in that company?

Assuming you are interviewing for a particular team, how similar or different is their culture?

For the first part, I'd ask

Does the IT department manage the Developer machines the same way they administer all the other machine?

What are the policies for adopting new technologies or new software?

For the second part:

How standardized is the development environment?

Can developers try out new tools and new technologies to introduce to the rest of the team?

What restrictions are there?

For the last part, ask other developers

What blogs do you read?

What blogs and web sites do you recommend?

In each case, the questions are on the edges and the answer will likely more honest.


问:
What is the difference between E-Science Infrastructures and Distributed Computing Infrastructures
What is the difference between eScience infrastructures and grid computing or distributed computing infrastructures? And what are some of their examples.

I can not distinguish them clearly. Is it how a grid is used make it an e-science platform?

答: eScience appears to be a British governmental term for Computational Science done on distributed computing systems and the surrounding infrastructure such as databases and the like. The term in the United States is "Cyberinfrastructure"...because it was the 90s and Al Gore was involved. Both appear to be largely governmental terms for specifically governmental projects involving large scale computing involving scientific research.</p>


答:
Your model is solid because you have a strong idea about the different types of content you want to manage (books, articles, etc.). Having a table for each type of content defines the different attributes. You can probably predict over 90% of the types you'll need for several years.

If you put them in one large table, you will have several columns that will be null. There are some databases that have improved the handling of sparse data and can save on space. From a data query perspective, you can include different types of content very easily.

I've seen several systems (mainly enterprise apps) where they provide greater flexibility for user-defined fields. Unlike your situation, they can't predict all the entities. A flexible way to do this is with a Entity Attribute Value Model. The joining of extra tables and possibly transposing row data into columns, performance is sacrificed over user flexibility. Basically, do you want your app to be programmer/code driven or user/data driven?

You may want to consider how you're going to handle searching. There are tools out there to make this easier. I've you're going to build your own, you have to deal with multiple tables.

Maybe a NoSQL solution should be considered?


问:
What are the advantages of storing xml in a relational database?
I was poking around the AdventureWorks database today and I noticed that a number of tables (HumanResources.JobCandidate and  Sales.Individual for example) have a column which is storing xml data.

What I would to know is, what is the advantage of storing basically a database table row's worth of data in another table's column? Doesn't this make it difficult to query off of this information? Or is the assumption that the data won't need to be queried and just needs to be stored?

答:
What are the advantages of storing a tree (XML) in a list of tuples (a database table)?

There is no reason why the XML shouldn't be queriable from your DBMS using e.g. XPath or SPARQL.

As I see it, they are simply two different data structures. And there is no reason why they shouldn't be embedded into one another.

You can look up the reasons for why the JSON datatype was added in PostgreSQL. I think many of the same arguments apply. Except that with XML/XSD, even more validation is possible.


问:
Is it ever ok to have an empty catch statement?
I thought about it and could not come up with an example. Why would somebody want to catch an exception and do nothing about it? Can you give an example? Maybe it is just something that should never be done.</p>

答:
IMO there is one place where empty catch statements are OK. In test cases where you expect an exception:</p>

```<code>try
{
   DoSomething(); //This should throw exception if everything works well
   Assert.Fail('Expected exception was not thrown');
}
catch(<whatever exception>)
{
    //Expected to get here
}
</code>```

Body:
IMO there is one place where empty catch statements are OK. In test cases where you expect an exception:

try
{
   DoSomething(); //This should throw exception if everything works well
   Assert.Fail('Expected exception was not thrown');
}
catch(<whatever exception>)
{
    //Expected to get here
}


问:
Predicting advantages of database denormalization
I was always taught to strive for the highest Normal Form of database normalization, and we were taught Bernstein's Synthesis algorithm to achieve 3NF. This is all very well and it feels nice to normalize your database, knowing that fields can be modified while retaining consistency.

However, performance may suffer. That's why I am wondering whether there is any way to predict the speedup/slowdown when denormalizing. That way, you can build your list of FD's featuring 3NF and then denormalize as little as possible. I imagine that denormalizing too much would waste space and time, because e.g. giant blobs are duplicated or it because harder to maintain consistency because you have to update multiple fields using a transaction.

Summary: Given a 3NF FD set, and a set of queries, how do I predict the speedup/slowdown of denormalization? Link to papers appreciated too.

答:
You would have to know the dataflows between the tables to be able to see how the DB model performs.
Once you have that you can calculate the change in performance for a given denormalization (e.g if you decide to duplicate data)

Some rough estimates can be deduced by how many new indexes you would need after the denormalization steps. Each new index must be updated and queried separately which will incur a performance hit proprtional to the number of new indexes.

Big blobs of binary data should in any case be stored in a separate table and not copied around. They are (usually) not queried but returned as part of the final result set after a query against some other set of tables.


答:
"Software rot" - is very vague term and can mean variety of thing to anyone, depending on how is your perception of the concept, as well as, what is your view angle.

Definition by Wikipedia on Software rot does not set a standard as it is also written by some individuals. I think this term has variety of meaning and needs to be broken down to the specific areas, where it is refereed.

Programmers may understand this as an un-maintainable code base with full of anti-patterns, no consistency in naming and coding style.

System admins may understand this as bad performance, full of memory leaks and hell.
maintenance.

End-user may understand this as very complicated, non-intuitive, hard-to-work software.

Title: Does software rot refer primarily to performance, or to messy code?

Body: Wikipedia's definition of software rot focuses on the performance of the software. This is a different usage than I am used to; I had thought of it much more in terms of the cleanliness and design of the code—in terms of the code's having all the standard quality characteristics: readability, maintainability, etc. Now, performance is likely to go down when the code becomes unreadable, because no one knows what is going on. But does the term software rot have special reference to performance? or am I right in thinking it refers to the cleanliness of the code? or is this perhaps a case of multiple senses of the term being in common usage—from the user's perspective, it has do with performance; but for the software craftsman, it has to do more specifically with how the code reads?


问:
How to manage long running background threads and report progress with DDD
Title says most of it. I have found surprising little information about this. I have a long running operation of which the user wants to see the progress (as in, item x of y processed). I also need to be able to pause and stop the operation. (Stopping doesn't rollback the items already processed.)

The thing is, it's not that each item takes a long time to get processed, it's that that there are usually a lot of items. And what I've read about so far is that it's somewhat of an anti-pattern to put something like a queue in the DB. I currently don't have any messaging system in place, and I've never worked with one either.

Another thing I read somewhere is that progress reporting is something that belongs in the application layer, but it didn't go into the details. So having said all this, what I have in mind is the following.

User request with list of items enters the application layer.

Application layer gets some information from the domain needed to process the items.

Application layer passes the items and the information off to some domain service (should the implementation of this service belong in the infrastructure layer?)

This service spins up a worker thread with callbacks for both progress reporting and pausing/stopping it.

This worker thread will process each item in it's own UoW. This means the domain information from earlier needs to be stored in some DTO.

Since nothing is really persisted, the service should be singleton and thread safe

Whenever a user requests a progress report or wants to pause/stop the operation, the application layer will ask the service.

Would this be a correct solution? Or am I at least on the right track with this? Especially the singleton and thread safe part makes the whole thing feel icky.

答: These types of operational concerns are the responsibility of the application layer and as such they are agnostic of DDD. The application layer delegates to the domain layer which can be implemented using DDD. It is atypical for a domain service to spin up worker threads and deal with processing status. Instead, it should be focused on implementing domain logic that does not naturally belong in an aggregate, entity or value object. Management of threads and processing status should be handled by the application layer because it is an operational concern, not a domain concern. There are multiple ways to implement long running processes with progress information. Using threads within an AppDomain is only one way to go. For example, if fault tolerance and distribution is required, it is best to place work items into a durable queue and have a message handler which processes these messages by delegating to the domain layer. Such an implementation is depicted in Request/Acknowledge/Poll With ASP.NET WebAPI and NServiceBus. Regardless of implementation of this application layer responsibility, the domain remains the same. </p>


答:
I'm not sure there is any academical research on when denormalizing can help (IMHO there is quite a big difference between what is taught about DB normalization and how it works in practice).

However, there are several interesting articles and blog entries about this _ Jeff Atwood speaks about normalizing in his blog, and there's a "reply" to him at high scalability.

When denormalizing, I suggest you pay attention to

the number and type of queries per unit of time; if you use insert and/or update more than read, denormalizing wouldn't be of much help.

how often the duplicated information will be updated

the characteristics of the DBMS you will use

how many times the information is duplicated; if you have the same information in 4-5 tables, it might be faster to keep it in a separate table rather than copy it so many times

the expected amount of data kept in DB; what might work for small amounts of data, can lead to a disaster if the number of records increases. And vice verse (I mean the KISS principle and not fixing what ain't broken).

Title: Predicting advantages of database denormalization

Body:
I was always taught to strive for the highest Normal Form of database normalization, and we were taught Bernstein's Synthesis algorithm to achieve 3NF. This is all very well and it feels nice to normalize your database, knowing that fields can be modified while retaining consistency.

However, performance may suffer. That's why I am wondering whether there is any way to predict the speedup/slowdown when denormalizing. That way, you can build your list of FD's featuring 3NF and then denormalize as little as possible. I imagine that denormalizing too much would waste space and time, because e.g. giant blobs are duplicated or it because harder to maintain consistency because you have to update multiple fields using a transaction.

Summary: Given a 3NF FD set, and a set of queries, how do I predict the speedup/slowdown of denormalization? Link to papers appreciated too.


答:
GlassDoor and Jobitorial are two options for this kind of intel.

Another strategy might be to go to local user groups and seek out people that work for the company and engage them in conversation. Tell them you are considering applying there and ask them questions.


问:
What's the worst question you were ever asked at interview?
It doesn't have to be programming or software development related, but just asked during an interview for an IT related job.

I know some "left field" questions are meant to see how the candidate copes with unexpected and novel situations, but here I'm looking for a question that appeared to be completely unrelated to the job they were interviewing you for, or something that made you think "what useful information could they possibly get from my answer to that question?".

答: I see from your resume you've spent some time in Israel... would you have a problem working with Palestinian co-workers?</p>


问:
Is COBOL still worth learning?
Does learning COBOL still make sense?</p>

答:
A lot of european companies still rely heavily on mainframes running like z/vse and cobol programs. There is a demand for skilled cobol programmers that noone thinks the market will fill which drives up the salary, a lot.

The question should be, "will I ever develop something new using cobol?" since pretty much everything is maintenance or variations of existing mission critical stuff.

Title: Is COBOL still worth learning?


问:
Java or C++ for university CS courses?
I'm in the throes of getting myself enrolled in school to get a CS degree. The school I am looking at actually offers both Java- and C++-based for the introductory software development courses (object-oriented programming, design patterns, that sort of thing). It is student's choice which track to follow, but there is only time to follow one.

Knowing what you know now, if you had the choice, would you lay down your CS curriculum foundation in Java or C++?

My current debate currently looks like this:

A good friend (who has a PhD in AI) is touting Java as the better choice regardless of what I do, if only to open up more job opportunities later, though he might be biased since all of his work has been in Java (he loves it). I live in the Boston, MA, USA area and I see an equal amount of Java and C work.

On the flip side, although I haven't entirely yet settled on what I want to do with the degree when I'm done, my preference would be to develop for the Mac, which I am doing now albeit in a limited capacity. To that end, I'm getting some limited exposure to C++ already, but I've had none with Java, and looking at my projects at my day job I don't see a need to use it anytime soon, "soon" measured by at least two years.

I probably should note that I'm an adult going back to school after 20 years (I currently have no degree of any kind) so I'm looking to maximize the opportunity and time spent as best I can. I'm kind of leaning towards C++ but I'm still ambivalent, and some outside, objective advice would help here.

Or I could just be thinking too hard about it.

UPDATE: It turns out the language selection wasn't so clear cut as I originally surmised. While a couple of core courses focused on Java, some of the other core courses work in primarily C and Java, but also a few others thrown in for good measure. In fact, my rest of my semester is going to be in Objective-C after spending time in Java and Javascript. Last semester was C, Javascript, and PHP, plus a few others thrown in as assignments required. Since things were pretty much split down the middle overall, and I am still getting answers to this, I am now trying to work my curriculum such that I meet all of the requirements for the degree but to absorb as many languages as I can reasonably handle. So far, my grades have not suffered trying to do this.

答:
I think the bigger question to ask yourself is do you want to be a good programmer or focus on computer science. If CS is your goal and you want to be on a PHD route then perhaps Java is the way to go. Java provides the Java collections classes, which have lots of premade data structures and algorithms. The advantage of this is twofold: First is that you get to play around with the data structures and algorithms to see what they do before worrying how they were constructed. Second, this provides the professors more opportunity to teach CS principles that use data structures without having to worry about the nitty gritty. Later on they can go back and have their students create the structures from scratch.

C++ on the other hand is a lower level language. It forces you to consider pointers and garbage collection. The learning curve is a little steeper but in the end when you find yourself down the road programming with external frameworks you will feel less like you are just relying on hidden magic. Furthermore, many larger companies are still using C++. It is more difficult to go from Java to C++ than C++ to Java.

Title: Java or C++ for university CS courses?


问:
How to teach Exception Handling for New Programmers?
How do you go about teaching Exception Handling to Programmers. All other things are taught easily - Data Structures, ASP.NET, WinForms, WPF, WCF - you name it, everything can be taught easily.

With Exception Handling, teaching them try-catch-finally is just the syntactic nature of Exception Handling.

What should be taught however is - What part of your code do you put in the try block? What do you do in the catch block?

Let me illustrate it with an example.

You are working on a Windows Forms Project (a small utility) and you have designed it as below with 3 different projects.

UILayer

BusinessLayer

DataLayer

If an Exception (let us say of loading an XDocument throws an exception) is raised at DataLayer (the UILayer calls BusinessLayer which in turns calls the DataLayer), do you just do the following

```<code>//In DataLayer
try {
    XDocument xd_XmlDocument = XDocument.Load("systems.xml");
}
catch(Exception ex)
{
    throw ex;
}
</code>```

which gets thrown again in the BusinessLayer and which is caught in UILayer where I write it to the log file?

Is this how you go about Exception Handling?

答:
It probably wouldn't help a new programmer, but I found that I understood the concept of exceptions a lot better once I started using monads in functional programming.  A monad forces you to consider every "channel" through which data can travel into or out of a program, since all it does it provide a convenient abstraction to "hide" some of that data flow.

The idea that a function can have different types of output, and an exception is like a higher-priority type of return from the function is pretty neat.

Mind you, I understand that isn't how exceptions work in most language (implementation details), but in an abstract sense, that's what is happening.


答:
I have to disagree with most people advocating Java here. Learning C++, even if you haven't studied computer and microprocessor architecture, gives you so many invaluable insights in the way computer programs work and operate.

Nota bene, I'm NOT advocating  you shouldn't learn Java (better yet, C#) because these are modern , rapid application development langs and huge frameworks have been built around them giving you access to a lot of "free" functionality, like abstracted file access and similar, however a true software engineer should know at least some C++, C or at least assembler, because that's what separates you from the script-kiddie types.

Once you are reasonably proficient with C++, confident with memory management and STL, picking up Java/C# should be a breeze.

Title: Java or C++ for university CS courses?

Body:
I'm in the throes of getting myself enrolled in school to get a CS degree. The school I am looking at actually offers both Java- and C++-based for the introductory software development courses (object-oriented programming, design patterns, that sort of thing). It is student's choice which track to follow, but there is only time to follow one.

Knowing what you know now, if you had the choice, would you lay down your CS curriculum foundation in Java or C++?

My current debate currently looks like this:

A good friend (who has a PhD in AI) is touting Java as the better choice regardless of what I do, if only to open up more job opportunities later, though he might be biased since all of his work has been in Java (he loves it). I live in the Boston, MA, USA area and I see an equal amount of Java and C work.

On the flip side, although I haven't entirely yet settled on what I want to do with the degree when I'm done, my preference would be to develop for the Mac, which I am doing now albeit in a limited capacity. To that end, I'm getting some limited exposure to C++ already, but I've had none with Java, and looking at my projects at my day job I don't see a need to use it anytime soon, "soon" measured by at least two years.

I probably should note that I'm an adult going back to school after 20 years (I currently have no degree of any kind) so I'm looking to maximize the opportunity and time spent as best I can. I'm kind of leaning towards C++ but I'm still ambivalent, and some outside, objective advice would help here.

Or I could just be thinking too hard about it.

UPDATE: It turns out the language selection wasn't so clear cut as I originally surmised. While a couple of core courses focused on Java, some of the other core courses work in primarily C and Java, but also a few others thrown in for good measure. In fact, my rest of my semester is going to be in Objective-C after spending time in Java and Javascript. Last semester was C, Javascript, and PHP, plus a few others thrown in as assignments required. Since things were pretty much split down the middle overall, and I am still getting answers to this, I am now trying to work my curriculum such that I meet all of the requirements for the degree but to absorb as many languages as I can reasonably handle. So far, my grades have not suffered trying to do this.


问:
What's your favourite quote about programming?
What's your favourite quote about programming?

One quote per answer, and please check for duplicates before posting!

答:
Not really a programming quote, more of an IT one, but one that my A-Level IT teacher drummed into me aged 16:

Typing is no substitute for Thinking

LastEditorDisplayName: Roger Pate


答: I believe there are certain cases where it is justified to have an empty catch clause - these are cases when you want the code to just keep going if a particular operation fails.  However, I do think that this pattern can be easily overused, so each use should be closely examined to make sure there's not a better way to handle it.  In particular, this should never be done if it leaves the program in an inconsistent state or if it could lead to some other part of the code failing later on.</p>

Title: Is it ever ok to have an empty catch statement?

Body: I thought about it and could not come up with an example. Why would somebody want to catch an exception and do nothing about it? Can you give an example? Maybe it is just something that should never be done.</p>


问:
How do programming languages benefit from being based on English?
I think the world now programs in English-based programming languages not only because of historical/economic circumstances, but because the English morphology in particular has some properties that suit algorithmic thinking best. But anyway it would be interesting to hear your opinions on this, especially if you are multilingual yourself.

I've seen some mentioning of German-based languages (see Plankalkul for example, in fact the first ever programming language we know very little about, thanks to WW2), also a Russian-based flavor of Algol which existed back in the 80's at least on paper, not sure if it ever existed in binary or not. Both looked a bit sluggish because there were more shortened words and weird abbreviations than full words like in the EN-based languages. So if you know of any other national language-based PL's, even completely archaic and irrelevant today, purely theoretical or whatever, would be interesting to take a look at them.

And back to the main question: so what, if any, makes the Shakespeare's language so good for programming?

(There is actually a list of Non-English-based programming languages on Wikipedia (of course, where else?), but it would be interesting to hear opinions of native speakers of those languages on how a given "national" programming languages really feels like.)

答:
The only reason that english is widely used in computing is that it happens to be a wide spread language right now.

If computers were invented 2000 years ago, they would have used Greek. If they were invented 200 years ago they would have used French. If they would have been invented in 200 years they would probably use Chinese...


答:
I'd recommend C++. I had some classes in Java, and some in C++ in college, and the language specific skills I learned from C++ have helped me more when learning additional languages later. Additionally, although I see a lot more Java than C++ job openings, most are looking for a full Java stack, like:

EJB 1.x/2.0, JNDI, JMS, JTA/JTS, RMI, JDBC, Servlets, JSP, SAX/DOM, Web Services, SOAP, WSDL, UDDI, JAXB, JavaMail, WAP, WML, HTML

Tomcat, Apache Xalan, Apache Xerces, Jserv, JRun, JBuilder, TogetherJ, Web Logic 5.x/6.x, Websphere 3.5/4

And chances are a Java based curriculum won't prepare you much better than a C++ based one would against a list like that.

Title: Java or C++ for university CS courses?


问:
How should I create lo-fi (non-interactive) UI prototypes?
I'm currently working on throwing together some basic prototypes, partly to gather requirements and partly to design the final UI.

At the moment I'm trying building up the screen using Post-it notes, with yellow notes for information and pink for actions (buttons or menus). The idea being that you can easily move, remove and add information. But I'm sure there are more efficient methods out there.

What is the recommended way for developers to efficiently create non-interactive UI prototypes?

And why?

I tried some pen, paper and Post-it note versions and they went down like a lead balloon (likely my drawing skills). In the end I used Balsamiq, which thus far is liked by most users and they get it is prototype. Alas, some people are still having problems with the idea that first one should get an idea of what the application should do via some lo-fi prototypes and really want to "see something on the screen" before committing to anything.

答:
I've done rapid prototyping in Delphi several times. It makes it easy to very quickly throw together a screen layout, much quicker than in powerpoint or visio. The resulting exe can be attached to e-mails without requiring any dependencies. Since I use it to prototype web apps, there's no danger of people confusing the prototype with a halfway finished version.

I've tried to do the same with Sencha Ext Designer, but the layout system of Ext JS is harder to use, and it felt like more of a burden than a convenience to rapidly iterate ideas.


问:
What did Linus Torvalds mean by his quotation about portability?
In a debate with Andrew Tanenbaum over microkernel vs. monolithic operating system architecture, Linus Torvalds said,

Portability is for people who cannot write new programs.

What did he mean by that?

答:
Although some people view/treat portability, following standards, etc., as morally superior, or something on that order, what it really boils down to is economics.

Writing portable code has a cost in terms of effort to make the code portable, and (often) foregoing some features that aren't available on all targets.

Non-portable code has a cost in terms of effort to port the code when/if you care about a new architecture, and (often) foregoing some features that aren't (or weren't) available on the original target.

The big qualifier there is "when/if you care about a new architecture". Writing portable code requires effort up-front in the hope of an eventual payoff of being able to use that code on new/different architectures with little or no effort. Non-portable code lets you delay that investment in porting until you're (at least reasonably) sure you really need to port to some particular target.

If you're sure up-front that you're going to port to a lot of targets, it's usually worthwhile to invest up-front in minimizing long-term porting costs. If you're less certain about how much (or even if) you'll need to port the code, writing non-portable code lets minimize the up-front cost, delaying or possibly even completely avoiding the cost of making the code portable.

I think it's also worth noting that I've spoken of "portable" and "non-portable" as if there was a clear-cut division between the two. In reality, that's not true -- portability is a continuum, running from thoroughly non-portable (e.g., assembly code) to extremely portable (e.g., Info-zip), and everywhere in between.


答:
I use a combination of MS Paint and Visual Studio. I use VS to drag/drop all the controls I want onto a form, then screenshot it into MS paint to rearrange them until I like the way it looks.

This way I can use simple, familiar, free, and always-accessible tools (for me) to mock up my UI, and the client can see the UI as it will probably look once the application is finished. In addition, often VS ends up containing the beginning of my project for me.

Edit: Toby's answer lead me to Balsamiq, and that is now my primary tool of choice for UI mockups to present to other people.

I still pull out MSPaint or pen/paper on occasion, but that's usually only when I'm sketching basic UI design for my own reference, or if I want to present the client with two options for a completed screen (ex. "Do you want the buttons Here or Here?")

Title: How should I create lo-fi (non-interactive) UI prototypes?

Body:
I'm currently working on throwing together some basic prototypes, partly to gather requirements and partly to design the final UI.

At the moment I'm trying building up the screen using Post-it notes, with yellow notes for information and pink for actions (buttons or menus). The idea being that you can easily move, remove and add information. But I'm sure there are more efficient methods out there.

What is the recommended way for developers to efficiently create non-interactive UI prototypes?

And why?

I tried some pen, paper and Post-it note versions and they went down like a lead balloon (likely my drawing skills). In the end I used Balsamiq, which thus far is liked by most users and they get it is prototype. Alas, some people are still having problems with the idea that first one should get an idea of what the application should do via some lo-fi prototypes and really want to "see something on the screen" before committing to anything.


问:
How to find out if a company has insane policies
When interviewing for a job, is there a delicate yet accurate way to find out if they have insane policies, like "no open source", or "no installing software without permission", "not upgrading software until it's about to lose support", or "no visiting blogs"?</p>

答:
First thing's first - ask all you are worried about, don't leave anything to assumptions. I cannot stress this enough - I once assumed something and later regretted it.

Secondly, and this is (IMHO) quite important too  : Ask them if you can walk around company offices.

Observe the people working there. If there is something wrong, you'll "just know it". Part of this comes from stressed people releasing all sorts of pheromones, and the other part comes from the eery, inexplainable silence, one of the sort of the wood being chopped in the forrest in which there is no one to hear the sound of it falling.


答:
I think a lot depends on your personality. At least from my perspective, Java and C++ have radically different orientations that appeal to substantially different kinds of people.

When you get down to it, Java is really mostly a big class library, with enough of a language to be able to instantiate objects and invoke methods from that library. "Learning Java" consists, in large part of memorizing (or at least becoming aware of) what's in the library and how it's organized, so you can find the things you want when you want them.

C++ places much less emphasis on providing pre-written code. While it does include a library (STL1), that library is less about the code that's included than it is about a style and set of principles. It's entirely possible to write code that's clearly and easily recognizable as "STL" code, even though it uses little or even none of the pre-written code at all.

There's also a fairly substantial difference in how the languages are used. Java has placed a heavy emphasis on keeping the language simple. This makes it easy to build tools that manipulate Java code in various ways (e.g., for refactoring). It also means that you tend to need tools that can do so, because refactoring often involves quite substantial changes to large amounts of code.

C++ is a much more complex language, which means (among other things) that building tools to manipulate C++ source code is tremendously more difficult than for Java. The balance to that is that it's much less necessary -- a refactoring job that might involve hundreds of changes to dozens of files in Java might be accomplished by (for example) changing a single template parameter in C++.

Java places a great deal more emphasis on being easy to learn. C++ places much more emphasis on being easy to use -- but (unfortunately) only if you really know what you're doing.

I'm not going to advocate for one or the other. My opinion of the languages is a lot less relevant than your having some idea of what to expect from each, and taking an honest look at yourself to figure out which is likely to suit you better.

1Yes, I know that's not really accurate, but I'm trying to keep this from turning into a book...

Title: Java or C++ for university CS courses?


答:
Having taught both C++ and Java at the college level, I would strongly recommend Java.

Java assists in the learning process, and encourages good programming behavior. The built-in libraries for Java are useful and easily available in every install. Being able to create a GUI app in one sentence, using the built-in libraries available in every Java install and that match all the tutorials the students find in a Google search, is crucial to helping students get beyond the language and start understand programming concepts.

The IDEs for Java provide support for both beginning and continuing students. Bringing powerful refactoring tools into the conversation early (while discussing OOP, for example) will help students learn to write maintainable code.

While C++ is a useful language to know, the additional concepts learned in C++ are not really worth the extra effort of the language as a whole. There are a large extra set of "gotchas" that must be taught around that can be introduced at a later time (memory management problems and buffer overflows to name a couple). Requiring students to understand these before moving on to concepts like algorithmic complexity and inheritance slows you down, the way requiring a driver to understand tire pressure before driving would slow down Driver's Ed. Sure, you need to know it. But you only need to know it as something that you'll get wrong some day, not as a building block of a larger concept.

Title: Java or C++ for university CS courses?


问:
Do you ever read language specs?
While trying to answer questions on SO site (particularly C++ questions) I find that most of the times one person or the other includes a quote from the standard. I myself have hardly read the language spec. Even when I try to read it, I can't get my head around the language used in the specs. So, my question to become a good developer in a particular language is it essential to read its spec and know all its dusty corners which invoke undefined/implementation defined behavior? </p>

答: I've read the Haskell spec, which is useful not just for the language definition but also because it contains source code for the Haskell Prelude. Reading the Prelude code gave me a good grasp of common Haskell idioms.</p>

Title: Do you ever read language specs?


答: Once I had insomnia for a few days so I read the whole ECMA published C++/CLI spec. What a great read.</p>

Title: Do you ever read language specs?

Body: While trying to answer questions on SO site (particularly C++ questions) I find that most of the times one person or the other includes a quote from the standard. I myself have hardly read the language spec. Even when I try to read it, I can't get my head around the language used in the specs. So, my question to become a good developer in a particular language is it essential to read its spec and know all its dusty corners which invoke undefined/implementation defined behavior? </p>


问:
Doesn't "if (0 == value) ..." do more harm than good?
This is one of the things that I hate most when I see it in someone else's code. I know what it means and why some people do it this way ("what if I accidentally put '=' instead?"). For me it's very much like when a child goes down the stairs counting the steps out loud.

Anyway, here are my arguments against it:

It disrupts the natural flow of reading the program code. We, humans, say "if value is zero" and not "if zero is value".

Modern compilers warn you when you have an assignment in your condition, or actually if your condition consists of just that assignment, which, yes, looks suspicious anyway

You shouldn't forget to put double '=' when you are comparing values if you are a programmer. You may as well forget to put "!" when testing non-equality.

答: I wouldn't call it harm, but it is obnoxious. So no I wouldn't say it does.</p>


答: I've never felt that the whole 'what if I forget a =?' ever really held much weight. Yes, you may make a typo, but we all make typos, it seems silly to change your entire coding style because you're afraid of making a mistake. Why not make all of your variables & functions all lowercase with no puncuation, because you might forget to capitalize something or forget an underscore one day?</p>

Title: Doesn't "if (0 == value) ..." do more harm than good?

Body:
This is one of the things that I hate most when I see it in someone else's code. I know what it means and why some people do it this way ("what if I accidentally put '=' instead?"). For me it's very much like when a child goes down the stairs counting the steps out loud.

Anyway, here are my arguments against it:

It disrupts the natural flow of reading the program code. We, humans, say "if value is zero" and not "if zero is value".

Modern compilers warn you when you have an assignment in your condition, or actually if your condition consists of just that assignment, which, yes, looks suspicious anyway

You shouldn't forget to put double '=' when you are comparing values if you are a programmer. You may as well forget to put "!" when testing non-equality.


答:
This is basically flaimbait.

No, it doesn't do more harm than good. Simple.

More words?

Compiler argument? Erm, ish, maybe - don't put too much faith in the complier to save you from yourself.

"You shouldn't forget" - well duh - no of course you shouldn't meanwhile I'm tired, I've been coding all day I've had to use two different languages and sometimes, just sometimes, being human I make a mistake.

The point of this sort of behaviour is that its defensive, its not there because you expect to make mistakes any more than you have insurance because you expect to crash... but if you do its nice to be covered.

Hard to read? You're complaining that a decent programmer should have == hardwired (which makes all kind of poor assumptions) but that the self same decent programmer can't read 0 == value ??

Does no harm, has potential benefits, silly question, let others do it if they want and move on.


答:
Harmful?  No.  It works either way.

Bad Practice?  Debatable, at best.  It's simple defensive programming.

Worth losing sleep over?  Nah.


答:
And yet the errors occur. And sometimes you want an assignment in a loop operator where you might otherwise check equality, or at least it is standard practice to use it.

I hold with it somewhat.The advice that I have followed ( possibly from Code Complete ) is to keep what should be the lower value on the left in comparisons. I was discussing this with a colleague earlier and he thought it was kind of crazy but I've got very used to it.

So I would say:

```<code>if ( 0 <= value )
</code>```

But I would also say:

```<code>if ( value <= 100 )
</code>```

Equality I will tend to check with the variable on the left though, it's just more readable.

Body:
And yet the errors occur. And sometimes you want an assignment in a loop operator where you might otherwise check equality, or at least it is standard practice to use it.

I hold with it somewhat.The advice that I have followed ( possibly from Code Complete ) is to keep what should be the lower value on the left in comparisons. I was discussing this with a colleague earlier and he thought it was kind of crazy but I've got very used to it.

So I would say:

if ( 0 <= value )

But I would also say:

if ( value <= 100 )

Equality I will tend to check with the variable on the left though, it's just more readable.


问:
What causes overtime and how can it be avoided?
Today, my manager told me that I must work over time to make up for a lack of planning and project management. Instead of incentivizing this unpaid mandatory overtime, my manager has made it clear I have no choice in the matter.

This isn't a single project. We currently have a dozen projects all on the go at one time, and I simply can't get them all done. Therefore, I must work overtime so we don't have to push deadlines.

Is this a sign of an ignorant or disrespectful manager, or simply an inexperienced one?

I'm in this position because of a lack of planning and project management (I think). How might I avoid this in the future? I'm no Project Manager, it isn't my strength.

What are good ways to get an employee to work overtime if you can't directly pay them? Good incentives, etc.

From what I hear, gaining your employee's respect is the single best way to get your employees to work over time, although you should never make a habit of it.

答:
I can't tell from your question whether you have just messed up on one particular project and are being told you have to make it right, or whether your manager makes everyone meet deadlines even when the deadlines are ridiculous and inhuman effort is required to meet them.

If it's the latter, take a look at http://www.planningforfailure.com/post/1461931855/the-problem-with-working-overtime which makes all the points I would make here.

But if it's the former, you need to know whether this is a one-time wipe-the-slate-clean incident or not. He gave you a task, you blew it, you make it right by working real hard one week, and going forward it's as though you did it perfectly and on time? That might be ok. But he's going to keep on giving you tasks you can't quite do, isn't going to step in when you head in the wrong direction, hasn't provided any support for you, and figures it's all ok as long as you work 100 hours in any week that featured mistakes? You don't want to be there. Or you didn't do anything wrong, he just made up dates that required 2-3 times the pace you all know you can code at, meaning you had to work overtime to make him look ok. You don't want to be there either.

So when you get this done, you ask your boss: what just happened? Why did I have to work all that overtime? Was this my mess-up? Could we have seen it coming? How can I make sure it doesn't happen again? Is this normal?

And if the answers are a pat on the head, a thats-how-things-are-in-the-big-leagues-kid, even an I-know-it-wasn't-your-fault-but-projects-always-end-like-this, then you need to look to options that involve a different boss.

As to how not to be that guy, you're halfway to knowing already and you'll probably know the other half by the time you're management.


问:
How important is the ability to touch-type?
Did you learn to touch-type when you were already working as a programmer?  If so how did it affect your productivity?  Or are you still unable to touch type and do you think it holds you back?

According to Steve Yegge it is essential,

Personally I did not notice much difference, possibly because I was spending less than 25% of my work time actually typing (I was working on a large legacy project at the time and I was spending more time on reading and debugging existing code.)

答:
If you can't type as fast as you think, you're in for a long career.

Seriously, if you have to stop and think for a second about where the keys are or whatever, then you're spending too many brain cycles on it.

Learn to type, it's easy.


问:
Should I be involved in my project's business side?
Before my current job, I was always involved in the technical aspects of a project like:

architecture

design

performance

security

etc

Now I'm team lead of a project that's a game on a web site (not mine) and somehow got involved in the business side of the project:

what users expect

ads showing in which pages of the site

mechanics of the game

etc

But I quite don't agree with business people's (customer or product owner if you like) decisions of the directions of the site. Of course I raise my concerns, some of them are taken into account, most of them aren't.

I continue my work as usual as I like working here but I feel like the product would be better than what it is now. I think that's because my goal is to make an interesting and challenging game, and theirs is to attract as many people and earn money as possible (it's a paid game). Have you guys ever happened to be in this kind of situation? What are your experiences?

答:
Yes I have, in many companies I worked for. And I always lost to the business people; they have a higher rank in software companies anyway.

Curiously, making your product more interesting and more enjoyable for your users is the whole point of business: the more enjoyable, the more money, as a rule. On the other hand making money by not making your product better, more often than not means unethical business, which works in the short term and certainly fails in the long run.

In fact, you may be wrong and they may be right on some, or most, or all of the issues you disagree on, but anyway: start your own startup and end this frustration.


答:
To me, it's simple conditioning.  As someone who learned (in the 90's) C and C++, I grew accustomed to it and still use it, even though the reasons are lessoned.

Once you are "conditioned" to look at the left side for the "constant", it becomes second nature.

I also only use it for equivalence (or negated equivalence), not for greater/less than.

I completely agree w/ @Wonko's answer.


答:
It's difficult because Java is undeniably easier to learn. You will be doing more sooner with Java.

C++ is a much more difficult language to work with. Pointers and memory management are conceptually and practically tricky to work with. C++ doesn't offer you any safety nets.

In the long term it would be useful to understand all the things that C++ teaches you. Also the transition from C++ to Java is far easier than the other direction.

But I do wonder whether when starting out and during a lot of degree projects the extra overhead and debugging you have to do in order to get something working in C++ would actually make your projects harder, your deadlines tougher to meet and your life far more frustrating. To achieve the same thing in C++ and Java I would say that in almost every case you would get the job done faster in Java and run into fewer annoying problems. That could be a really big deal when you are at the end of a semester and have five courses needing their end of course project on the same day.

The other side of that is that if those trials don't cause you to throw in the towel altogether, they will make you a better programmer if you have mastered C++. And if your career is with C# or Java or python and you never have to touch another pointer in your life, you will appreciate it a whole lot more...

Title: Java or C++ for university CS courses?


答:
In many projects getting involved in the business side of things is not only inevitable, but good.  If you understand the owner's reasons for wanting things you can better react to/suggest/repair/anticipate features you need to work on.

Specifically to your final question: I have, and most of the time you loose more of these than you win until you start to get some positive history on being right with your suggestions.

One thing that sometimes has helped me is to make a demo with things my way and show it to the users as an alternative or conversely make a demo of enough of their way to point out the problems.

In most enterprise situations it is your job to bring the things up, but ultimately their decision if they think that their crazy is better.

When they choose the crazy the best thing you can do is make certain you have a clear exit strategy back to sane worked out when they realize their error.

If the crazy starts to get the better of you consider a different employer...

Title: Should I be involved in my project's business side?

Body:
Before my current job, I was always involved in the technical aspects of a project like:

architecture

design

performance

security

etc

Now I'm team lead of a project that's a game on a web site (not mine) and somehow got involved in the business side of the project:

what users expect

ads showing in which pages of the site

mechanics of the game

etc

But I quite don't agree with business people's (customer or product owner if you like) decisions of the directions of the site. Of course I raise my concerns, some of them are taken into account, most of them aren't.

I continue my work as usual as I like working here but I feel like the product would be better than what it is now. I think that's because my goal is to make an interesting and challenging game, and theirs is to attract as many people and earn money as possible (it's a paid game). Have you guys ever happened to be in this kind of situation? What are your experiences?


答: Consider a set of more direct questions after you've been made an offer. No need to be rude, but if you have any concerns...


答: I consider it very useful, and I'm glad I had to learn it at school, even though I hated it back then. BTW, my school was focused on IT and business organisation.</p>

Title: How important is the ability to touch-type?

Body:
Did you learn to touch-type when you were already working as a programmer?  If so how did it affect your productivity?  Or are you still unable to touch type and do you think it holds you back?

According to Steve Yegge it is essential,

Personally I did not notice much difference, possibly because I was spending less than 25% of my work time actually typing (I was working on a large legacy project at the time and I was spending more time on reading and debugging existing code.)


答:
The one case where I find it helpful is where the variable part of the if is quite long and seeing the values makes the code easier to read.  The dotted namespace languages have the best examples of this.

For example something I worked on with single sign-on had a situation where you could have two concurrent sessions if a certain type of error happened and was recovered a certain way so I have to add a handler for it that was inside an if that looked something like this:

if (2 <= application.httpcontext.current.session["thenameofmysessiontoken"].items.count())

Admittedly in this example there are other ways to do this, but this would be a case where the number-first version is potentially more readable.


问:
Is it ever ok to have an empty catch statement?
I thought about it and could not come up with an example. Why would somebody want to catch an exception and do nothing about it? Can you give an example? Maybe it is just something that should never be done.</p>

答:
In some cases, Java requires you to handle an exception that can, under absolutely no circumstances, ever happen. Consider this code:

```<code>try {
   bytes[] hw = "Hello World".getBytes("UTF-8");
}
catch(UnsupportedCodingException e) {
}
</code>```

Every implementation of the Java
platform is required to support the
following standard charsets.

...

UTF-8

Without breaking your Java platform, there is simply no way to ever cause this exception. So why bother handling it? But you cannot simply ommit the try-catch-clause.

Body:
In some cases, Java requires you to handle an exception that can, under absolutely no circumstances, ever happen. Consider this code:

try {
   bytes[] hw = "Hello World".getBytes("UTF-8");
}
catch(UnsupportedCodingException e) {
}

Every implementation of the Java
platform is required to support the
following standard charsets.

...

UTF-8

Without breaking your Java platform, there is simply no way to ever cause this exception. So why bother handling it? But you cannot simply ommit the try-catch-clause.


答:
I don't always use the same approach.  Some of the techniques I use are (in rough order of frequency):

Whiteboard (for prototyping interactively/discussing.  Take a photo afterward!)

RAD-style GUI designer (Visual Studio, NetBeans, Delphi)

Get good at this, and it can actually become one of the fastest ways to create prototypes of a "windows, widgets, and forms" application.  Bonus: the prototypes can end up looking really pretty professional, depending on how quickly you throw it together.  They can sometimes even serve as a launching point for creating the real thing, once a prototype is approved.

Paper and pen/pencil (usually for brainstorming to myself)

Static HTML/CSS/JS files on disk

I'd imagine a WYSIWYG design application wouldn't hurt here, but I usually just hack on the raw HTML.  I don't do a lot of these, anyway.

Vector drawing tools - Illustrator / Inkscape / Visio / PowerPoint / Impress

Raster graphics tools - Photoshop / Gimp

ASCII art ;-)


问:
Sprint Meetings - What to talk about
In work we have just started using the Scrum methodology, it is working well but I have a question on the daily sprint meetings.

We set aside 15 minutes for the meeting (between the three devs and the scrum master if we think he is needed) but I have found that we have normally finished by 5 minutes.

This might be because we have said all that needs to be said but I was wondering what people tend to talk about in them, in case we are missing something.

For the record we normally update each other on current objective, troublesome previous objectives and plans for the rest of the day (including if we will not be available on that project).

答:
The Scrum Master ensure that the process (Scrum) is properly implemented. He is mandatory in daily stand ups (it's how they are called).

15 minutes is OK for a team of 5 (3 minutes per team member). If you don't speak more than 1 minutes, it looks like a smell to me. Could you check you respect these rules?

Title: Sprint Meetings - What to talk about


答:
Just to add another set of answers:

Is this a sign of an ignorant or disrespectful manager, or simply an
  inexperienced one?

Possibly all of the above.  The question is whether this is the person's normal MO or is this an anomaly because someone is coming down hard on them.  How much experience does whoever is running the project have and how well was it planned out originally?  These are other things to consider here.  It may be that what was thought of as a "simple feature" is really anything but and this late discovery has caused some chaos to the project time line.

I'm in this position because of a lack of planning and project
  management (I think). How might I
  avoid this in the future? I'm no
  Project Manager, it isn't my strength.

My suggestion would be to consider ways to influence people so that you can hopefully take a so-so boss and make them good in a way.  While being a Project Manager may not be your strength, there is the question of what is the process for how some things go and who is calling the shots.  In some Agile places the team can have a fair degree of autonomy in deciding what gets put into a sprint which can be a piece of what a PM handles.  To some extent the question here is how does one handle stress as this can be an almost natural thing in some development environments, often not good but there may be that rare exception where the stress is a good thing for some people somewhere.

What are good ways to get an employee to work overtime if you can't
  directly pay them? Good incentives,
  etc.

In some places I've worked there were annual bonuses of which a part was based on your performance and so working extra hours may help count towards that would be my thinking.  In a way this is an indirect payment for those extra hours as who knows how many extra hours some may work to get that bonus.  Other places would allow one to have some "Comp time" which is basically time that could be taken off later as a kind of swap so that at some point you don't have to work so much in theory.  Hopefully this doesn't sound too creepy but I'd think if my boss befriended me that would be a way to get the situation into a, "Hey, could you give me a favor?" where I'd be asked to work X extra hours that is done out of kindness or as part of building the friendship.  If anyone is wondering about the creepiness that can be seen when someone is just trying to manipulate the situation and seems fake for trying to make a friend in bad times and then disrespect one in good times as that friend isn't needed any longer.  Another way to get some to do overtime is the bribing of food or beverages that can help ease the pains one can have in working extra time and possibly forgetting to get food or get some fluids as a reward, possibly alcoholic in some cases.

Title: What causes overtime and how can it be avoided?

Body:
Today, my manager told me that I must work over time to make up for a lack of planning and project management. Instead of incentivizing this unpaid mandatory overtime, my manager has made it clear I have no choice in the matter.

This isn't a single project. We currently have a dozen projects all on the go at one time, and I simply can't get them all done. Therefore, I must work overtime so we don't have to push deadlines.

Is this a sign of an ignorant or disrespectful manager, or simply an inexperienced one?

I'm in this position because of a lack of planning and project management (I think). How might I avoid this in the future? I'm no Project Manager, it isn't my strength.

What are good ways to get an employee to work overtime if you can't directly pay them? Good incentives, etc.

From what I hear, gaining your employee's respect is the single best way to get your employees to work over time, although you should never make a habit of it.


问:
Do non-manager coders in their forties or older out there sometimes regret about not being managers?
And why do most programmers quit coding and become managers so early compared to other areas? You can work as a construction worker, a lawyer, researcher, writer, architect, movie director for decades if not your whole life, without quitting the favorite thing you are doing. And yet most programmers think being a manager, or better, a non-coding manager is a cool thing and the ultimate goal of the software career. It's so rare to see an ordinary coder in his 40s or 50s (or 60s!) in a typical software company. Why?

(And I am for being a coder for as long as you love doing it.)

答:
Programmers can fed up with all of the politics and think they can fix it all if they become managers (And maybe they're right?)

Also, a lot of programmers "settle" in their 40s or 50s and work at some smaller company where they don't work as much over time because they have family.


答:
It's so rare to see an ordinary coder
  in his 40s or 50s (or 60s!) in a
  typical software company. Why?

I think this has more to do with our profession being relatively young than anything else.

I mean, for sure, there are people around who have been coding in COBOL or Fortran since the 1960s, but our field (and the Computer Science education population) only really started growing exponentially in the 1990s. So most people in the field are relatively young.

Title: Do non-manager coders in their forties or older out there sometimes regret about not being managers?

Body:
And why do most programmers quit coding and become managers so early compared to other areas? You can work as a construction worker, a lawyer, researcher, writer, architect, movie director for decades if not your whole life, without quitting the favorite thing you are doing. And yet most programmers think being a manager, or better, a non-coding manager is a cool thing and the ultimate goal of the software career. It's so rare to see an ordinary coder in his 40s or 50s (or 60s!) in a typical software company. Why?

(And I am for being a coder for as long as you love doing it.)


答:
I'm just shy of your threshold, but several of my colleagues above your threshold hated management duties.  Some did the management thing for a while, and then went back to coding.  Management is a completely different skill set, and what makes a good programmer makes a bad manager (and vice versa).

Honestly, the pull for management is due to the way most companies are structured.  Once you hit the ceiling as a coder, there is no further up you can go--which is also reflected in your paycheck vs. your manager's paycheck.  I have yet to see a company actually try what was written in "The Mythical Man Month".


答:
These may be obvious, but I'll just state a couple of thoughts:

Some may become managers due to the company growing and having been at the company for X years they are now promoted to being a manager, kind of a reward for surviving so long in the company.  There can be a power trip that comes with being a manager I'd imagine as I've never been a manager or want to be a manager.


答:
And yet most programmers think being a manager, or better, a non-coding manager is a cool thing and the ultimate goal of the software career.

They do? I have yet to meet one of those types that was coding because they loved it. Most that think this way are programming because they think they are going to make a lot of money doing it and think moving to management they will make more money. They may be right.

I am 42 and I love coding. I am currently in a team lead position that has management overtones and I hate that aspect of it. I love being in charge, but management duties suck ass. Honestly, I don't want to work on motivating my team, performance reviews, code reviews, etc. I see this as baby-sitting stuff. I expect them to be as motivated as I am, and when they are not it is frustrating.

Don't get me wrong, I like being a mentor and would actually love skipping middle management and go right to upper management. That appeals to me. I like thinking long term and making strategic decisions for the business. But middle managers are simply baby sitters who must watch and motivate their charges. I see this as a waste of my skills, to be honest.


答:
The intent of the stand-up meeting is to keep all of the team members informed of recent progress and any impediments that may hinder progress. If it only takes your team 5 minutes to accomplish that goal, then 5 minutes is the proper time and you shouldn't worry too much about it.

I tend to stick pretty much to the classic:

What I have accomplished since the last stand-up

What I'll be doing until the next stand-up

Any issues that I think might keep me from getting my tasks done

but if I need to I'll add

Anything new I've learned (about the system / environment) that I think the team needs to know

Quick thank-you acknowledgements for team-members who have helped me out in a significant way

The important thing is to share important and timely information quickly and concisely. If that's being accomplished, then the exact time-frame is secondary.

Title: Sprint Meetings - What to talk about

Body:
In work we have just started using the Scrum methodology, it is working well but I have a question on the daily sprint meetings.

We set aside 15 minutes for the meeting (between the three devs and the scrum master if we think he is needed) but I have found that we have normally finished by 5 minutes.

This might be because we have said all that needs to be said but I was wondering what people tend to talk about in them, in case we are missing something.

For the record we normally update each other on current objective, troublesome previous objectives and plans for the rest of the day (including if we will not be available on that project).


答:
Just point your manager to this classic and famous blog post by Erin Hoffman. EA later had to pay $14.9 million for unpaid overtime.

Can the company you work for afford this?

(That blog posting was featured in one of Joel's books.)


答:
I think it would be cool to a project manager, that is to say, someone who does maybe does code but definitely does design.  I like the coding but I love the design work.  So I guess that counts.  I'd leave coding if it meant I could do design work full time, but no place I know of actually has non-coding PMs.  </p>

<p>(And of course I'd still program as a hobby.  My hobby coding and my work coding share some aspects but are largely independent things to me.)</p>

Body:
I think it would be cool to a project manager, that is to say, someone who does maybe does code but definitely does design.  I like the coding but I love the design work.  So I guess that counts.  I'd leave coding if it meant I could do design work full time, but no place I know of actually has non-coding PMs.

(And of course I'd still program as a hobby.  My hobby coding and my work coding share some aspects but are largely independent things to me.)


答:
(these meetings are usually called daily scrums or "daily standup meetings".  The word "sprint" refers to the iteration, which is typically between 1 and 4 weeks long.)

If you're done in 5 minutes, that's great! (of course, I assume that you covered the required three questions in those five minutes.)

One of the things new scrum teams struggle with is that these meetings run much longer than 15 minutes and people deviate from the agenda to discuss requirements, design, prioritization, etc.  But it looks like you've mastered this element of scrum already.

Title: Sprint Meetings - What to talk about


问:
Is a Ruby 'Web App' designed differently than a PHP 'Web Site'?
From my understanding, Ruby is a language that can be used to creat desktop applications. How does this get converted into a 'Web App' - and is a 'Web App' really any different than a Web Site with interactivity? </p>

答:
Ruby is a programming language, and most 'Ruby web apps' (as you have heard the term) are composed using a web application framework, most commonly Ruby on Rails. There are some very good screencasts at http://rubyonrails.org/screencasts if you want to see how it's done.

Similarly, other programming/scripting languages (PHP, Python, C#, Java, etc.) use other techniques, tools, and frameworks to build similarly interactive web applications.

At the most fundamental level, they all end up at the same destination: an interactive web site. The main difference is in how you get there.


答:
This may be completely offsides, since I primarily do ASP.NET in C#, but I think I have still have some insights to the difference between a "web application" and an interactive web site.  It is largely an issue of whether you view the website as the product or the interface to the product.

With an interactive site, you're primarily selling the site itself.  I'd say this is becoming an unpopular model really but things like a particular company's website might still fall into this model.  There can be a database providing content, but generally each page carries a lot of it's content with it, and may require some custom code to achieve the pages goals.

A web application, on the other hand, is really about the service.  The web site is a just a form factor for it.  Blogs, twitter, stack overflow, CMS, Facebook, and so on are all web applications.  Typically there are less pages, more templates.  Very little content is actually on a given page, because its all being pumped up from the database.

The tools used and how they are used can also make a big difference.  With Ruby or ASP.NET, you can almost pretend like the website isn't even there.  You're just processing and pumping data like any application, but the end result is pushed out to a website instead of a form or something.  Very often, web applications have APIs and other access points that further distance them from the web.  RSS feeds were early examples, but these days you can write a client app that connects directly to Twitter through their API so that the web site itself is never actually involved.

An Application can be further distinguished by its generality.  A blog engine is a general purpose web application, that can be applied with different designs and content to create many unique blog sites.  A lot of Python or Ruby web apps are like this, and are further distinct from web frameworks.  I'm somewhat familiar with Pylons in Python, which is a framework for building apps, which are themselves the frameworks for hosted sites.

I might use Pylons to write the front-end for a general purpose warehouse management system, then sell that application to clients of my own.  Their designers might further customize my web application to have some static reporting pages, or some general info pages, and now that's a web site.

So the application really is distinct from the site and the web (and the framework, and the language).  It's not a straight division, lots of sites include a mix of static content and dynamic content.  And if its a web application then it needs a web site front end to support it (but it can support other front-ends as well, this is the key.)

SHORT VERSION
A web application has a web site (which is a front end for the application's functionality) but a web site need not have a full application stack to back it.  Its more a matter of intent than actual composition.

Title: Is a Ruby 'Web App' designed differently than a PHP 'Web Site'?

Body: From my understanding, Ruby is a language that can be used to creat desktop applications. How does this get converted into a 'Web App' - and is a 'Web App' really any different than a Web Site with interactivity? </p>


答:
Betwen 3 devs and the scrum master if we think he is needed.

Maybe you have a small number of people attending the meeting.
Or does anyone give 'No update'?? kidding.

I am using scrum as well. we have approximately 13~15 people attending on the daily stand up meeting. What I usually report are

Any QA delivery(yesterday and today..) with user story

If all the user story delivered to QA, I make sure to say "All the user stories are delivered to QA"

If I am fixing the bug, I report how many bugs were fixed yesterday and how many remains..

So, we have 2 weeks sprint. For the first week, I usually talk about user story delivery and the second week is all about bug fix~~

Title: Sprint Meetings - What to talk about


答:
Although I'm not quite in my 40s yet I don't have long to wait...so I'll have a go at answering this one.

I'm a manager who also codes. I would hate to ever have a management position where I do no (or little coding). First of all I love coding (or more accurately problem solving and learning) but also if you're directly managing coders I feel you really do need to understand what's going on in order to support the team.

On the other hand I enjoy the managerial parts of my job - getting processes implemented, coaching and so forth. To be honest I don't think that most coders are interested in that side of things - when I go to 'soft skills' community events there's always way fewer people attending than go the coding or tech events. So, I don't know that most coders aspire to become managers (or if they do the ones that go to the tech events either aren't interested in the skills in the same way or they value them less).

I think the reason you don't get many 40+ coders is that 20 years ago there was a fraction of the number there are today - give it another 10-20 years and you'll see that age distribution even out a lot.


答:
In any highly technical field, you have to keep learning just keep up. Of course, not everyone can do this or really wants to try. Management is a perfect escape since the higher you climb, the less technical knowledge you're expected to have. I'm seriously generalizing here and not trying to diminish natural managers but a typical VP isn't supposed to design device drivers (or whatever).

What's difficult is not knowing if this reasonable transition is the right thing to do. I was fortunate enough to have gotten my answer when I was rather young. I had a minor, non-technical management position that taught me that I would NEVER want to be a real manager. For me, the pay difference just isn't worth the hassle and the technical stuff is just too much fun.


答:
I've always wondered if all those students that hated programming in university, but still graduated, will end up being our bosses?

I know a few colleagues that graduated with me that were more into politics than programming. I wonder if a corporation was big enough they would end up being managers? They knew enough about coding but had a natural aptitude for people management. With a software background they would have the skills to delegate and interact with other programmers.

It always seemed an irony to me that those that were really good at programming were one day going to be working for their peers that struggled through the same computer course.