答:
Sometimes several flags are crammed into a single byte to save space. Sometimes it's premature, other times critical.

Microsoft SQL Server will store multiple columns of data type "bit" in the same byte. In this case it's not a premature optimization. You save 2 to 8 times the disk space, for 2 to 8 bit columns (this is a big deal). You get faster searches as well (very big deal). It's also more likely you will be able to cache a set of data in memory. This is perfect. Since there is no benefit in indexing binary data, you might as well pack the bits together. And the bitwise nature is not exposed to client programmers so everyone is happy.

The windows API crams several options per byte. You manipulate the display options with bitwise operations. I would say this one was premature. It also made many people give up on windows programming. But the programmers who wrote the API came from the old days when space was severely limited. At the time it may have been a good idea to design an API around bitwise manipulation.

Client/server video games love to pack multiple flags in a byte. For example, on the server the game calculates your damage. It will send back the display data to the client, with several flags like if it was a critical hit, if it killed the enemy, etc. The display would then process with bitwise operations.  This is debatable whether it's premature or not. But I would lean towards saying less is more when pushing data over a network.

Title: Is it any good to use binary arithmetic in a C++ code like "C style"?

Body:
I like the fact that the C language lets you use binary arithmetic in an explicit way in your code, sometimes the use of the binary arithmetic can also give you a little edge in terms of performance; but since I started studying C++ i can't really tell how much i have seen the explicit use of something like that in a C++ code, something like a pointer to pointer structure or an instruction for jumping to a specific index value through the binary arithmetic.

Is the binary arithmetic still important and relevant in the C++ world?
How i can optimize my arithmetic and/or an access to a specific index?
What about the C++ and the way in which the bits are arranged according to the standard?

... or i have taken a look at the wrong coding conventions ... ?


问:
"Opportunity" to take over maintenance of a small internal website. What should I do?
I have been offered an "opportunity" to take over maintenance of a small internal website run by my group that provides information about schedules and photos of events the groups done.

My manager sent me the link to the site and I checked it out. The site looked clean and neat but loaded in ~5 seconds. I thought this was a little long considering the site really didn't contain a lot of content. This prompted me to take a look under the hood at the pages source code. To my horror it'd been totally hacked together using nested tables!

I'm new so I really can't say no to this "opportunity" so what should I do with it?

Every fiber of my being feels that the only correct thing to do is overhaul the site using CSS, Div's, Span's and any other appropriate tags that a sane/good web developer would used to begin with instead of depending on the render incentive magic of tables.

But I'd like to ask programmers with more experienced then me, who have been in this situation. What should I do?

Is my only realistic option to leave the horror as is and only adjusting the content as requested? I'm really torn between good development and the corporate reality I'm part of. Is there some kind of middle ground where things can be made better even if they're not perfect?

Thanks ahead of time.

Edit:

I've been looking into this a little deeper and noticed an extension type that rendered as HTML but was actually ".cfm". After looking into it I found out this was a ColdFusion file. Which is apparently an Adobe WYSIWIG program which must have been used by my predecessor to create this site.

This means maintenance will be trivial once I get a copy of ColdFusion. I will probably still need to do things like create thumb nails and move some of the content on the home page elsewhere to improve load times. I doubt I can go much further in optimizing the site past this without throwing out ColdFusion.

I am very grateful for all the good advice and will keep it in mind for future "Opportunities".

答:
Visibility & usability matters in web

I would agree with the comments that you may turn this task to a learning experience. You also get the most attention by fixing some usability issues that were left their for years. Thus, before starting to do any work, try to speak with end-users and get their feedback besides the requirements.

Identifying what is valuable

However, your work appreciation will directly depend on importance level of the project and how much your Boss values the progress. Thus, avoid any major re-factoring works and concentrate on visibility, usability and speed. That might be your Golden goose which might bring you, the work appreciation and joy of doing something valuable.

ContentLicense: CC BY-SA 3.0


问:
What's wrong performing unit test against concrete implementation if your frameworks are not going to change?
First a bit of background: We are re-architecting our product suite that was written 10 years ago and served its purpose. One thing that we cannot change is the database schema as we have 500+ client base using this system. Our db schema has over 150+ tables. We have decided on using Entity Framework 4.1 as DAL and still evaluating various frameworks for storing our business logic.

I am investigation to bring unit testing into the mix but I also confused as to how far I need to go with setting up a full blown TDD environment. One aspect of setting up unit testing is by getting into implementing Repository, unit of work and mocking frameworks etc. This mean there will be cost and investment on the code-bloat associated with all these frameworks. I understand some of this could be auto-generated but when it comes to things like behaviors, that will be mostly hand written. Just to be clear, I am not questioning the important of unit testing your code. I am just not sure we need all its components (like repository, mocking etc.) when we are fairly certain of storage mechanism/framework (SQL Server/Entity Framework). All that code bloat with generic repositories make sense when you need a generic layers with ability to change this whenever you like however its very likely a YAGNI in our case. What we need is more of integration testing where we can unit-test our code with concrete repository objects and test data in database. In this scenario, just running integration test seem to be more beneficial in our case. Any thoughts if I am missing any thing here?

答:
Unit testing against the database means you actually have a test database. In general, that is overhead in and of itself. The sort of overhead that isn't the rock solid, repeatable, concurrent type that unit tests need to be effective.

DB is down? tests fail.

Network is down? tests fail.

Working from home? tests fail.

Someone didn't deploy the test data properly? tests fail.

Someone running another test at the same time? tests fail if
you're not careful.

Your tests should only ever fail in one case: the thing they're specifically designed to test does not pass their assertion.

Now these can mostly be dealt with by having a locally deployed database new each time from test data. But how is that really any different from Mock repositories (except being slower and more error prone)?


问:
Single statement if block - braces or no?
Which is better/more generally accepted?

This:

```<code>if(condition)
{
  statement;
}
</code>```

Or:

```<code>if(condition)
  statement;
</code>```

I tend to prefer the first one, because I think it makes it easier to tell what actually belongs in the if block, it saves others from adding the braces later (or creating a bug by forgetting to), and it makes all your if statements uniform instead of some with braces and some without.  The second one, however, is still syntactically correct and definitely more compact.  I'm curious to see which is more generally preferred by others though.

答:
I go with the second. It's more succinct and less verbose.

I try not to write to the lowest common denominator, so I expect that other developers know how to write one of the single most common control flow structures in programming today.

ContentLicense: CC BY-SA 2.5


问:
How do Programmers in the East see programmers in the West?
The other half of this question: How do programmers in the West see programmers in the East?

I think it's just as interesting and important to see how programmers in the east view programmers in the west.

The eastern part of the world (India/China/Philippines ) is often seen as mainly providing outsourcing services to the western world (USA and Europe).

Do you have the experience of working as part of an offshore team? If yes, how was it?

Do you hold any generalized ideas or opinions about the programmers from the West (e.g. Are they cooperative, do they deliver on time or do they do quality work?)

答:
Chinese here.

I've worked with programmers from India, USA, England and most of the time, I work with chinese programmers. Here is how I feel:

1. India people work very hard. It seems that they're born to be diligence. But it seems that they just take it as a "job", because the result is not in proportion to the working hours, in terms of productivity.

2. Americans work with highly enthusiasm, most of them believe what they're working on is great and that's what they pursue. Mostly, the result is equal to their devotion and concentration. More importantly, they can take programming as a life-time occupation and it's very common there.

3. Although Tim Berners-Lee is from Britain, it seems that most British are not so interested in this field. They take it as a "job" too, much like Indians.

Here comes what Chinese programmers are like:(not off the topic, I guess)

1. Most of people in this field take it as "job", much like Indians and British.

2. Programmers appear more and more in those "Top 10 profession" lists regarding income as well as risk (in life).

3. Programmers here get "retired" or switch to other jobs after the age of 40. Mostly, they've been thinking of that since they are 32 or 35.

4. What really lack of here is open environment and innovative culture. We have many passionate people and creative ideas here but the passion and ideas are hidden in the dark. We need to guide them to shout it out and take action.

Silicon valley is the dream working place and hopefully there could be silicon valley everywhere across the world. All the programmers can be passionate and innovative, pursuing their dream, and most of all, can work on it a life-time.


答:
Nested Tables Aren't Necessarily Bad

There are things you can do with nested tables that you can't with CSS and
s, especially with regard to re-sizable width layouts.  Tables may be old fashioned, but they are more versatile and work equally well on every browser.  I personally prefer CSS where it works equally well on every browser and use tables where it doesn't.  More than 3 levels of nested tables is almost always unnecessary.

Tables Aren't Slow

Have you looked at the timings in the developer console of a browser to find out what is causing it to be slow?  If you don't identify the cause of the slowness, you aren't going to be able to fix it.  I think I've seen layout issues slow down a web site's display 1% of the time.  The other 99% of the time it is waiting for the server or the network - most often to download images.

Technology Doesn't Matter

This is not a customer-facing site.  If the site displays well-enough on everyone's browser, the only person who will care about the technology behind it is you.  Your boss's goal, I'm sure, is that you keep it functional and spend as little time on it as possible.

Clean up each page you have to change for a business reason to meet the most basic standards you can stomach and leave the rest.  For me, that means making pages validate cross-browser Xhtml 4.0 transitional with Quirks-mode properly disabled (using the special doctype/html-tag combination) for IE.  Why do I tilt at that particular windmill?  Because I don't like surprises.  When a new version of a browser comes out I don't want to have to run and fix the site.  The HTML Validator plug-in for Firefox is great for this.

If you can do a little something to make yourself more productive in the future and/or make the html valid over time, do it.  Otherwise, start a manifesto of what changes the site needs and plan to make those changes another time.  As your manifesto grows, it will help you remember all the issues, identify your most serious pain points, and keep you focused on the low-hanging fruit that will actually make a difference to the people who use the site.  And what will make a difference to your boss is how quickly you can say, "OK, next project."

If this were customer facing, if it were production code, I would give you very different advice - care is critical there.  But not here.

Title: "Opportunity" to take over maintenance of a small internal website. What should I do?

Body:
I have been offered an "opportunity" to take over maintenance of a small internal website run by my group that provides information about schedules and photos of events the groups done.

My manager sent me the link to the site and I checked it out. The site looked clean and neat but loaded in ~5 seconds. I thought this was a little long considering the site really didn't contain a lot of content. This prompted me to take a look under the hood at the pages source code. To my horror it'd been totally hacked together using nested tables!

I'm new so I really can't say no to this "opportunity" so what should I do with it?

Every fiber of my being feels that the only correct thing to do is overhaul the site using CSS, Div's, Span's and any other appropriate tags that a sane/good web developer would used to begin with instead of depending on the render incentive magic of tables.

But I'd like to ask programmers with more experienced then me, who have been in this situation. What should I do?

Is my only realistic option to leave the horror as is and only adjusting the content as requested? I'm really torn between good development and the corporate reality I'm part of. Is there some kind of middle ground where things can be made better even if they're not perfect?

Thanks ahead of time.

Edit:

I've been looking into this a little deeper and noticed an extension type that rendered as HTML but was actually ".cfm". After looking into it I found out this was a ColdFusion file. Which is apparently an Adobe WYSIWIG program which must have been used by my predecessor to create this site.

This means maintenance will be trivial once I get a copy of ColdFusion. I will probably still need to do things like create thumb nails and move some of the content on the home page elsewhere to improve load times. I doubt I can go much further in optimizing the site past this without throwing out ColdFusion.

I am very grateful for all the good advice and will keep it in mind for future "Opportunities".

Body:
Nested Tables Aren't Necessarily Bad

There are things you can do with nested tables that you can't with CSS and <div>s, especially with regard to re-sizable width layouts.  Tables may be old fashioned, but they are more versatile and work equally well on every browser.  I personally prefer CSS where it works equally well on every browser and use tables where it doesn't.  More than 3 levels of nested tables is almost always unnecessary.

Tables Aren't Slow

Have you looked at the timings in the developer console of a browser to find out what is causing it to be slow?  If you don't identify the cause of the slowness, you aren't going to be able to fix it.  I think I've seen layout issues slow down a web site's display 1% of the time.  The other 99% of the time it is waiting for the server or the network - most often to download images.

Technology Doesn't Matter

This is not a customer-facing site.  If the site displays well-enough on everyone's browser, the only person who will care about the technology behind it is you.  Your boss's goal, I'm sure, is that you keep it functional and spend as little time on it as possible.

Clean up each page you have to change for a business reason to meet the most basic standards you can stomach and leave the rest.  For me, that means making pages validate cross-browser Xhtml 4.0 transitional with Quirks-mode properly disabled (using the special doctype/html-tag combination) for IE.  Why do I tilt at that particular windmill?  Because I don't like surprises.  When a new version of a browser comes out I don't want to have to run and fix the site.  The HTML Validator plug-in for Firefox is great for this.

If you can do a little something to make yourself more productive in the future and/or make the html valid over time, do it.  Otherwise, start a manifesto of what changes the site needs and plan to make those changes another time.  As your manifesto grows, it will help you remember all the issues, identify your most serious pain points, and keep you focused on the low-hanging fruit that will actually make a difference to the people who use the site.  And what will make a difference to your boss is how quickly you can say, "OK, next project."

If this were customer facing, if it were production code, I would give you very different advice - care is critical there.  But not here.


问:
Why are many programmers moving their code to github?
For the past 6 months or more, I've been seeing many codes hosted at sourceforge.net as well as other hosting sites "Move to GitHub". A mere Google Search with the phrase "Moved to Github" returns several results containing the text moved to github. This is very confusing for me, and I'm wondering, why exactly are people moving? Does it mean that GitHub is better or is there some special advantage I'm not seeing?</p>

答:
You've also got to take into account some pretty smashing features offered by github that I've yet to see mentioned.

github pages with github flavored markdown

github mobile app

github eclipse plugin

github for mac

github jobs

github for windows

github ticketing/bug tracking system

github developer api which allows for seamless third party
integration

frequent UI updates/enhancements (you can literally see the changes
from one day to the next i.e. search text box now dynamically expands
on focus, watch became the new star button, etc.)

github gists (good
for utility scripts, short code snippets, etc.)

seamless github integration via hub

Other sites may have these features but I'm pretty sure no site out there has them all.

These guys are practically everywhere...slowly dispersing their technical goodies throughout the web and desktop alike. They're only getting bigger and better as we speak and they hire the finest of engineers (they even managed to steal Phil Haack from Microsoft...go figure).


问:
Alternative way of developing for ASP.NET to WebForms - Any problems with this?
So I have been developing in ASP.NET WebForms for some time now but often get annoyed with all the overhead (like ViewState and all the JavaScript it generates), and the way WebForms takes over a lot of the HTML generation.

Sometimes I just want full control over the markup and produce efficient HTML of my own so I have been experimenting with what I like to call HtmlForms.

Essentially this is using ASP.NET WebForms but without the form runat="server" tag. Without this tag, ASP.NET does not seem to add anything to the page at all. From some basic tests it seems that it runs well and you still have the ability to use code-behind pages, and many ASP.NET controls such as repeaters.

Of course without the form runat="server" many controls won't work. A post at Enterprise Software Development lists the controls that do require the tag.

From that list you will see that all of the form elements like TextBoxes, DropDownLists, RadioButtons, etc cannot be used. Instead you use normal HTML form controls. But how do you access these HTML controls from the code behind?

Retrieving values on post back is easy, you just use Request.QueryString or Request.Form.

But passing data to the control could be a little messy. Do you use a ASP.NET Literal control in the value field or do you use <%= value %> in the markup page? I found it best to add runat="server" to my HTML controls and then you can access the control in your code-behind like this: ((HtmlInputText)txtName).Value = "blah";

Here's a example that shows what you can do with a textbox and drop down list:

Default.aspx

```<code><%@ Page Language="C#" AutoEventWireup="true" CodeBehind="Default.aspx.cs" Inherits="NoForm.Default" %>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN""http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
    <head runat="server">
    <title></title>
</head>
<body>
    <form action="" method="post">
        <label for="txtName">Name:</label>
        <input id="txtName" name="txtName" runat="server" /><br />
        <label for="ddlState">State:</label>
        <select id="ddlState" name="ddlState" runat="server">
            <option value=""></option>
        </select><br />
        <input type="submit" value="Submit" />
    </form>
</body>
</html>
</code>```

Default.aspx.cs

```<code>using System;
using System.Web.UI.HtmlControls;
using System.Web.UI.WebControls;
namespace NoForm
{
    public partial class Default : System.Web.UI.Page
    {
        protected void Page_Load(object sender, EventArgs e)
        {
            //Default values
            string name = string.Empty;
            string state = string.Empty;
            if (Request.RequestType == "POST")
            {
                //If form submitted (post back)
                name = Request.Form["txtName"];
                state = Request.Form["ddlState"];
                //Server side form validation would go here
                //and actions to process form and redirect
            }
            ((HtmlInputText)txtName).Value = name;
            ((HtmlSelect)ddlState).Items.Add(new ListItem("ACT"));
            ((HtmlSelect)ddlState).Items.Add(new ListItem("NSW"));
            ((HtmlSelect)ddlState).Items.Add(new ListItem("NT"));
            ((HtmlSelect)ddlState).Items.Add(new ListItem("QLD"));
            ((HtmlSelect)ddlState).Items.Add(new ListItem("SA"));
            ((HtmlSelect)ddlState).Items.Add(new ListItem("TAS"));
            ((HtmlSelect)ddlState).Items.Add(new ListItem("VIC"));
            ((HtmlSelect)ddlState).Items.Add(new ListItem("WA"));
            if (((HtmlSelect)ddlState).Items.FindByValue(state) != null)
                ((HtmlSelect)ddlState).Value = state;
        }
    }
}
</code>```

As you can see, you have similar functionality to ASP.NET server controls but more control over the final markup, and less overhead like ViewState and all the JavaScript ASP.NET adds.

Interestingly you can also use HttpPostedFile to handle file uploads using your own input type="file" control (and necessary form enctype="multipart/form-data").

So my question is can you see any problems with this method, and any thoughts on it's usefulness?

I have further details and tests on my blog.

答:
The problems that I see:

Non-standard way of working: you are coming up with your own, fairly non-standard way of working.  Any new developers you hire will have to learn the details of your framework.  Some of them may not like it (e.g. see some of the comments above), and refuse to work in it.  As you go along, you will also keep (re-)inventing lots of basic functionality, like data-binding, which is essentially a waste of your efforts.

Not using the technology's strengths: WebForms are an attempt to bring event-driven programming to the web.  To enable this by default, a lot of state has to be passed around all the time.  By working around this, you are losing most of the functionality and benefits of WebForms.

Existing technologies that do this already: There are excellent technologies that do what you are trying to do, but in a much better way.  ASP.Net MVC is probably the best known.  If you would like to develop in a style that is closer to the way the web actually works (and would like a framework which helps in that), try it.  It really is an excellent technology, a bit of fresh air compared to WebForms.


问:
What's a good, quick algorithms refresh?
I have programming interviews coming up in a couple weeks.  I took an algorithms class a while ago but likely forgot some key concepts.

I'm looking for something like a very short book (< 100 pages) on algorithms to get back up to speed.  Sorting algorithms, data structures, and any other essentials should be included.  It doesn't have to be a book...just looking for a great way to get caught up in about a week.

What's the best tool for a quick algorithms intro or refresher?

答:
I used this book at my university having been a necessary book for the course, but I've  found it to be quite thorough.  It's quite handy to have around as a reference as well.

If you'd prefer an online source, you should take a look at this site.


问:
Google Closure Compiler - what does the name mean?
I am curious about the Google Closure Compiler. Why did they name it that? Does it have anything to do with lexical closures?

EDIT: I tried researching it in the FAQ and documentation, as well as doing Google searches such as "closure compiler name". I couldn't find anything definite, hence the reason I am asking. I don't think I will get a profoundly helpful answer but I was hoping that I could at least satisfy my curiosity.

I am not trying to solve a specific problem. I am just curious.

答:
Michael Bolin, author of the book "Closure - The Definitive Guide" and former Google Employee talked about the origins of the name "Google Closure" in the preface of his book:

When I worked at Google from 2005 to 2009, I used Closure to help
  build Google Calendar and Google Tasks. When the initial work on
  Calendar was done in 2005, only the Compiler was available, and it was
  (and is) known internally as the JavaScript Compiler.

  ...

  Meanwhile,
  the JavaScript codebase for Gmail had grown so large and complex that
  developers complained that it was too hard for them to add new
  features. This triggered a rewrite of the Gmail client, which
  precipitated the development of the two other major tools in the
  Closure suite: The Library and the Templates. The Library was simply
  named "Closure", as it was a play on the programming construct used so
  frequently in JavaScript, as well as the idea that it would bring
  "closure" to the nightmare that was JavaScript development at Google.


答:
I'm currently enjoying this book

The examples are written in Java but can easily be adapted to other languages. It's very practical, but not as mathematically thorough as some other books.

Amazon link

Book website

Title: What's a good, quick algorithms refresh?

Body:
I have programming interviews coming up in a couple weeks.  I took an algorithms class a while ago but likely forgot some key concepts.

I'm looking for something like a very short book (< 100 pages) on algorithms to get back up to speed.  Sorting algorithms, data structures, and any other essentials should be included.  It doesn't have to be a book...just looking for a great way to get caught up in about a week.

What's the best tool for a quick algorithms intro or refresher?


问:
What are the advantages of using a template language?
I work on a CakePHP app and the views consist of raw html with embedded php echo statements, which over time has gotten rather messy. Before I go in and rewrite the code, I'm wondering if it makes sense to rewrite the views with a template engine, such as Twig or Smarty, but I don't have experience with template engines. What are all the advantages of using a template engine?</p>

答:
I have been using MVC design pattern for a few years.

MVC allows you to separate your business logic (Model) from your user interactions (controller) and templates (views).
I've worked with Zend_View for a long time, and I wouldn't use a template engine with it. http://framework.zend.com/manual/1.12/en/zend.view.html


问:
What should be the minimal design/scope documentation before development begins?
I am a junior developer working on my own in the programming aspect of projects.

I am given a png file with 5-6 of the pages designed, most times in specific detail. From this I'm asked to develop the back end system needed to maintain the website, usually a cataloging system with products, tags and categories and match the front end to the design.

I find myself in a pickle because when I make decisions based on assumptions about the flow of the website, due to a lack of outlining details, I get corrected and am required to rewrite the code to suit what was actually desired.

This process happens multiple times throughout a project, often times on the same detail, until it's finally finished, with broken windows all through it.

I understand that projects have scope creep, and can appreciate that I need to plan for this, but I feel that in this situation, I'm not receiving enough outlining details to effectively plan for the project, resulting in broken code and a stressed mind.

What should be the minimal design/scope documentation I receive before I begin development?

答:
I've found that there is no single answer. No Golden Rule.

Each client and proejct requires different level of specifications.

One thing is vital to all though - communication. To the best of your ability, make the client understand what you are doing and why. Make sure to discuss each aspect of the website and undestand every bit of it.

I would advice you to do the following:
- what is the end goal.
- what this site does
- who uses it
- How this site helps the bussiness

Aim to answer those questions before even thinking in terms of coding. After you clearly understand what your client wants/needs THEN forget all about it and focus on implementation.

I had clients giving me a brief 5 min talk to exaplin a system that will take 2 months to display. And I had specifications written on 10 pages that would take 2 days of development.

Its important to remember that we serve a purpose in the client's bussines - we create something for them and we need to know WHAT that thing is


问:
"Do you have any questions for us?" In an interview
You know the prospective company fairly well but are asked "Do you have any questions for us?".  To show interest, what are some of your favorite questions to reply?</p>

答:
do you have trainings ?

do you have team buildings ?

how is the workload ?

do you send the developers abroad, to the client ?

do you encourage certifications ?

do you send developers to conferences ?

do you have a budget for books ?


问:
Is shipping a Clojure desktop app realistic?
I'm currently shipping a desktop Java application. It is a plain old Java 5 Java / Swing app and so far everything worked nicely. Java 5 was targetted because some users were on OS X version / computers that shall never have Java 6 (we may lift this limitation soon and switch to a newer Java and simply abandoning my users stuck with Java 5).

I'm quickly getting up to speed with Clojure but I haven't really done lots of Clojure-to-Java and Java-to-Clojure yet and I was wondering if it was realistic to ship a Clojure desktop application instead of a Java application?

The application I'm shipping is currently about 12 MB with all the .jar so adding Clojure doesn't seen to be too much of an issue.

My plan would be to have Clojure call Java APIs: my application is already divided in several independent jars.

If I understand correctly calling Clojure from Java is harder than calling Java code from Clojure which is why I'd basically rewrite all the UI (part of the UI, mixing Swing components and self-made BufferedImages needs to be rewritten anyway due to the rise of retina display),  and do all the 'wiring' from Clojure.

So that's the problem I'm facing: is it realistic to ship a Clojure desktop app? (it certainly doesn't seem to be very widespread but then shipping plain Java desktop apps ain't that common either and I'm doing it anyway)

Technically, what would need to be done? (compared to shipping a Java app)

答:
Yes, it is entirely realistic - not many people seem to be doing it yet but I think that is only a matter of time (Clojure is pretty new after all!)

I've personally written an open-source game in Clojure which runs as a Swing application (https://github.com/mikera/ironclad) so have some experiences to share which may be useful.

On average you probably want to have Clojure call into Java APIs. This is mostly common sense - Java has all the great libraries, Clojure is the more productive language for gluing things together.

You may want to write a Java-based "loader" with a main(...) method that launches the Clojure part of the code. Among other things, this means that you won't have to AOT compile your Clojure code. Example code here: https://github.com/mikera/ironclad/blob/master/src/main/java/ic/IronClad.java

You will probably want to do things like throw up a splash screen while your application initialises to allow for the extra startup time loading/compiling Clojure code. It probably adds 1-2 seconds to a typical app startup time, which is enough that your user will probably appreciate some feedback. If you are clever, you can actually throw up the whole UI while other stuff loads in the background but this requires some care and might test your concurrency kung-fu :-)

You can mix Java and Clojure relatively freely since they can call backwards and forwards fairly transparently. The only complication if you want Java to call Clojure is that Java likes to know the class / interface it is calling at compile time. A good option is to have Clojure code dynamically implement an aleady-compiled Java interface via reify.

I've found it pretty easy to develop and package an app in a single jar containing both Clojure and Java code using Eclipse/Maven. The Clojure code can simply be put in src/main/resources and gets loaded / compiled at runtime.

You can use Clojure GUI wrappers like seesaw if you like. It seems to be pretty good. I decided against using it, mainly because I wanted to do some fiddly things with Swing directly and didn't feel that I needed an extra layer of abstraction.


问:
Test Driven Development Code Order
I am developing my first project using test driven development. I am using Zend Framework and PHPUnit.

Currently my project is at 100% code coverage but I am not sure I understand in what order I am supposed to write my code.

Am I supposed to write my test FIRST with what my objects are expected to do, or write my objects and then test them?

I've been working on completing a controller/model and then writing a test for it but I am not sure if this is what TDD is about.

Any advice?

For example, I wrote my Auth plugin and my Auth controller and tested that they work properly in my browser; then I sat down to write the tests for them which proved that there were some logical errors in the code that did work in the browser.

答:
Test first. TDD is also IOW called "test-first development".

What you have been working at is not TDD.

TDD is 1-2-3:

Write a failing test.

Make it pass (committing any sins and shortcuts during the way).

Remove duplicities (logical, not just physical).

In shorter words this is also advertised as "make it fail / make it work / make it right".

More in Kent Beck's awesome book Test-Driven Development By Example.

Title: Test Driven Development Code Order


问:
Android, OpenGL and extending GLSurfaceView?
This question is part-technical, part-meta, part-subjective and very specific:

I'm an indie game dev working on android, and for the past 6 months I've struggled and finally succeeded in making my own 3D game app for android. So I thought I'd hop on SO and help out others struggling with android and openGL-ES

However, the vast majority of questions relate to extending GLSurfaceView. I made my whole app without extending GLSurfaceView (and it runs fine). I can't see any reason at all to extend GLSurfaceView for the majority of questions I come across.

Worse, the android documentation implies that you ought to, but gives no detailed explaination of why or what the pros/cons are vs not extending and doing everything through implementing your own GLSurfaceView.Renderer as I did

Still, the sheer volume of questions where the problem is purely to do with extending GLSurfaceView is making me wonder whether actually there is some really good reason for doing it that way vs the way I've been doing it (and suggesting in my answers to others to do).

So, is there something I'm missing? Should I stop answering questions in the meantime?

Android openGL documentation

答:
I have a very minimal extension for my GLSurfaceView, and most of the wisdom belongs to my implementation of GLSurfaceView.Renderer. I had the following three reasons to use a wrapper for GLSurfaceView:

The base GLSurfaceView provides no way to get the Renderer instance back. I have multiple surfaces, and when I receive a UI event for one of them, I want to pass the command to the corresponding renderer. So, I override setRenderer and keep the reference in my extended class.

GLSurfaceView.Renderer does not receive notifications for onDetachedFromWindow() or surfaceDestroyed(). This caused some problems to my implementation. My extension of GLSurfaceView overrides these methods and lets the mRenderer know. It's possible because of §1.

Some methods are only wrapped to add try { super.whatever; } catch() { log(whatever) }. For example, queueEvent() will throw if Renderer is not set; but for me, it's OK to simply ignore such timeline inconsistencies.


问:
How to integrate technical line/functional manager into Scrum team?
We have recently had a new line manager start to manage our Scrum team. He is immensely experienced in our field but is relatively inexperienced at Agile/Scrum. He has extensive technical expertise in embedded software (the team's domain) that would go to waste if not utilised properly.

However, the team is wary of making a line manager part of the Scrum team. The general consensus is that the line manager should not be part of the Scrum team at all. There are a number of issues that may crop up, e.g. the team may start "reporting" to the manager (i.e. a daily status update!), the manager may start to micro-manage team members etc etc.

As it currently stands, he has already said that he feels like an outsider within the team. We really want to make use of his technical skills, we'd be foolish if we didn't because we are a relatively inexperienced and young team of twenty somethings.

What would be the best approach to integrate a senior "technical" line manager in a Scrum team and make him feel like he is part of the team?

答:
The question is whether the manager would be responsible for actively creating your deliverables, or is he really simply providing information and organizational skills.  In scrum speak, is he a "pig" or is he a "chicken?"  If he's actively helping with the coding and the testing and actually has real tasks with real deliverables in each Sprint, he should definitely be part of the team.  Otherwise, he's a SME that you should utilize as needed.

That said, get the poor guy some training in Scrum before he starts messing with team dynamics.


答: Take a look at TopCoder Algorithm Tutorials. They are very informal, which lets them stay short and to the point - a luxury no serious algorithm book can afford. The goal of these tutorials is to refresh your knowledge if you studied these algorithms before, or to give you an initial direction in exploring a particular group of algorithms.</p>


问:
Questions to ask before someone leaves
Apart from the obvious questions relating to specific project work someone is working on are there any questions I should be asking a fellow dev who is leaving the company?

So far I am thinking about;

Locations of things on the server he uses that not maybe everyone does.

Credentials he has set up that we wouldn't have needed.

Client details he has not yet saved into our CRM system.

答:
Commit early, commit often.

When someone is planning to leave is not the time to make sure their work has been checked into source control, their contacts put in your CRM system, their documentation written... these things should be followed up on every day for every employee, regardless of how long you expect to have them.  Some people get hit by buses, you know (literally or figuratively), and even if there is time to prepare for someone's exit from your organization, during that time period their focus is not likely to be 100% on you, no matter how much they intend it to be.  A constant cycle of documentation is the answer to all of these woes.

When exit time nears...

I'm absolutely sold on the suggestions to make sure to have contact information for your former employee, and arrange a consulting fee for those "oh, shoot, we need to find out how $thing works" moments.

In addition to that, I'd ask for:

A to-do list for the next couple of days, so you can farm out whatever he would be doing until your workflow has adjusted to him not being there.

A list of what he thinks you should look for in his replacement.  Asking "what went wrong?" is less probative in my opinion: If he's unhappy with the company, you are more likely to get an emotional answer than a logical one.  If he's happy with the company, you are likely to get a non-answer because he won't want to burn bridges.

Asking about his potential future replacement, on the other hand, is more likely to reveal useful information, because he's not being asked to focus on you or him or your relationship.  The future replacement doesn't exist yet, so no one thinks about offending him/her.  It's easier to say, "look for someone who is at least moderately interested in managing others, rather than a straight coder" than "you gave me too much management responsibiliy; I'm a coder, not a manager".

When you find out that someone is, indeed, leaving, ask "what can we do to make the transition easier, for us and for you?".  This goes a long way to show the departing employee that you care about him not just in terms of what you can get out of him, and more importantly shows your other employees that you feel that way about them.  There are often little things you can do ("let me work this Saturday so I can take off Monday for the closing on our new house") that cost you little to nothing, but give the departing employee real incentive to put effort and attention into making the transition work for you.  That motivation can make a huge difference in how he approaches handing things off and documenting what needs documenting, because it eliminates (or at least reduces) the feeling of "this relationship is already over, we're just going through the motions for two weeks".

Hope that helps,

--Susan

Title: Questions to ask before someone leaves


答:
Define the search criteria

It might be waste of time to dive into all arbitrary algorithm book and try to grasp something out of it. Instead, i would suggest to look at practical algorithm books tailored toward real-world problems in software development process. In addition, having examples in the programming language of your choice is another point to consider.

Thus, i would suggest to look at content, examples and readability before picking one and refreshing my knowledge.

Here you are two good references that may help you to decide:

list of books in programming algorithms

list of books practical programming algorithms


答:
Beware of the Iceberg Syndrome!

With an iceberg, the vast majority of it is located under the water, with just a small percentage being visible. Likewise with a website, the vast majority of it is hidden out of view from the user.

Changing the site from nested tables to CSS/DIV's will take a considerable amount of time and effort, none of which will be visible to the users and managers. If you spend a month working on this change, to your managers it will look as if you have done nothing at all for the month. This could be very bad for your career, especially if you are new to the company.

I would take on the role of maintaining the site and continue to keep it up-to-date, while making small changes here and there to tidy up the architecture of the site, but I wouldn't waste too much time on it.

If it works, don't fix it.

You will almost certainly make some small mistakes somewhere, be it a typo or a DIV that doesn't quite align correctly. These are the only parts of your effort that anyone is going to see, and they are going to have a negative impact on their perception of the site, and therefore yourself. You could end up doing more harm than good to your career.


问:
Is script grouping and minification counter-productive?
On a web page I have 1 script tag that contains all my minified JavaScript (I use SquishIt for .NET).

However I see that a few people prefer to load their scripts in parallel using something like requirejs or headjs.

I was wondering which is better for performance and whether combining and minifying all my JavaScript is worth the effort?

答:
Browsers will download up to 6 files in parallel from the same domain: http://www.browserscope.org/?category=network&v=top

This includes stylesheets, images, and so on. For optimal performance, you should combine resources to make sure that no more than 6 (parallel) requests are needed to load everything on the page. This means combining script files, combining images into CSS sprites, combining stylesheets and so on. If you need to load more, you need to split the requests across domain names.

As far as minification, it depends on how big the file is. Minifying a small file won't give much advantage, but minifying a large file can make a real difference on slow network connections, even when combined with gzip compression. See https://stackoverflow.com/questions/807119/gzip-versus-minify

Solutions like requirejs are meant for loading scripts not needed to initially show the page, but needed instead to interact with it. Even there combining scripts is recommended to stay under the 6 requests threshold.


答:
In a lot of teams, including mine, the product owner is also a manager for some or all of the team members, so it's hardly uncharted territory.  It does pose some difficulties, and for some teams is wholly unworkable, but this is what helped for us:

The manager and the scrum master must have an open relationship.  It won't work if the scrum master is afraid to address issues with the manager.

The manager must have enough self awareness to realize when his actions are causing problems, and have enough self control to step back, at the very least when the scrum master brings it to his attention.

The team must be confident enough to stand up to the manager when it is in the best interest of the process.

The best thing may be for the manager to not always be there.  When we noticed people doing the daily status update to the manager, he stopped coming to the scrums for a while.  Some of our team members are still uncomfortable with increasing an estimate with him present, so he often steps out during more sensitive parts of our estimation meetings.

Some meetings are explicit scrum meetings, like your daily standup, iteration planning, and retrospective, but you generally also have design meetings and reviews that are part of making good software.  The latter are a lot more important to have experienced technical guidance in than the former.

Title: How to integrate technical line/functional manager into Scrum team?

Body:
We have recently had a new line manager start to manage our Scrum team. He is immensely experienced in our field but is relatively inexperienced at Agile/Scrum. He has extensive technical expertise in embedded software (the team's domain) that would go to waste if not utilised properly.

However, the team is wary of making a line manager part of the Scrum team. The general consensus is that the line manager should not be part of the Scrum team at all. There are a number of issues that may crop up, e.g. the team may start "reporting" to the manager (i.e. a daily status update!), the manager may start to micro-manage team members etc etc.

As it currently stands, he has already said that he feels like an outsider within the team. We really want to make use of his technical skills, we'd be foolish if we didn't because we are a relatively inexperienced and young team of twenty somethings.

What would be the best approach to integrate a senior "technical" line manager in a Scrum team and make him feel like he is part of the team?


问:
Web Page Execution Internals
My question is what is the subject area that covers web page execution/loading.

I am looking to purchase a book by subject area that covers when things execute or load in a web page, whether it's straight html, html and Javascript, or a PHP page.

Is that topic covered by a detailed html book, or should I expect to find information like that in a JavaScript of PHP book?

I understand that PHP and Perl execute on the server and that Javascript is client side, and I know there is a lot of on-line documentation describing , , , and so on. I'm just wondering what subject area a book would be in to cover all that, not a discussion of the best book or someone's favorite book, but the subject area.

答:
There is a generic sequence of events that happens. You may get a better understanding how page is downloaded and parsed by just looking at F12-Developer tool (which really cool tool in Chrome).

Basic execution flow will have the following stages:

Page Request is sent to server (through url)

Web server accepts the request and handles it

On success, server site scripts are executed, and HTML generated for transmission

All that is done through HTPP request/response

On HTTP status code 200 - standard response for successful HTTP requests is sent

Html is downloaded

Html parsed progressively,

after HTML is parsed the DOM is rendered

after the DOM rendered and requests for all resources are downloaded ot timed-out the JavaScript execution from the onload/page complete event fires.

More detailed information with example: - Load and execution sequence of a web page

Title: Web Page Execution Internals


答:
I'm not entirely sure what you are asking, but here are a few areas that you may want to look at:

Web Servers - Handling and processing requests and replying with the required documents or data

HTTP Protocol - Handles the request and transmission of files and other web requests

Browser Rendering - Drawing of the resulting data of a HTTP Request on the page

You then have each individual technology which will be covered by their own books, such as HTML, CSS, Javascript etc, however most of these will be tutorials on how to code using these technologies rather than descriptions of how they are rendered and processed.

What exactly is it you are trying to achieve? It may be easier to point you in the right direction if you can say what you are trying to achieve.

Title: Web Page Execution Internals

Body:
My question is what is the subject area that covers web page execution/loading.

I am looking to purchase a book by subject area that covers when things execute or load in a web page, whether it's straight html, html and Javascript, or a PHP page.

Is that topic covered by a detailed html book, or should I expect to find information like that in a JavaScript of PHP book?

I understand that PHP and Perl execute on the server and that Javascript is client side, and I know there is a lot of on-line documentation describing , , , and so on. I'm just wondering what subject area a book would be in to cover all that, not a discussion of the best book or someone's favorite book, but the subject area.


答:
I usually use braces, but there are some cases where I don't.

```<code>object GetObject() {
    // calculate obj1
    if(obj1 != null)
        return obj1;

    // calculate obj2
    if(obj2 != null)
        return obj2;

    // calculate obj3
    if(obj3 != null)
        return obj3;

    return defaultObj;
}
</code>```

To me, it would just be silly to add them there. If someone adds a statement after the return, we have bigger problems than scoping issues.

Title: Single statement if block - braces or no?

Body:
Which is better/more generally accepted?

This:

```<code>if(condition)
{
  statement;
}
</code>```

Or:

```<code>if(condition)
  statement;
</code>```

I tend to prefer the first one, because I think it makes it easier to tell what actually belongs in the if block, it saves others from adding the braces later (or creating a bug by forgetting to), and it makes all your if statements uniform instead of some with braces and some without.  The second one, however, is still syntactically correct and definitely more compact.  I'm curious to see which is more generally preferred by others though.

Body:
I usually use braces, but there are some cases where I don't.

object GetObject() {
    // calculate obj1
    if(obj1 != null)
        return obj1;

    // calculate obj2
    if(obj2 != null)
        return obj2;

    // calculate obj3
    if(obj3 != null)
        return obj3;

    return defaultObj;
}

To me, it would just be silly to add them there. If someone adds a statement after the return, we have bigger problems than scoping issues.


问:
Windows driver signing
My company is developing driver for our hardware. Now I need to sign my driver for 32 and 64 bit platforms.

Please tell, now I need to buy Authenticode certificate, right?

What CA to use?

DigiCert?

GlobalSign? ( http://www.sslshopper.com/microsoft-authenticode-certificates.html )

Symantec? ( http://www.symantec.com/verisign/code-signing/microsoft-authenticode )

What is the difference between this CA offers?

I need to use tools from WDK?

答:
Yes, you'll need a code signing or Authenticode certificate.  (It looks like not all CA vendors call it an Authenticode certificate; GoDaddy, for example, simply calls it a driver signing certificate.)

As far as I know, with one major exception (see below), there is very little difference between CA vendors, and I'd generally just recommend using whoever's cheapest.  Our Authenticode certificate is through Verisign / Symantec; I don't have experience with the other vendors.  From my shopping around for regular (not code signing) SSL certificates, it seemed that companies like Verisign charged a premium just because they were better known.  (It's possible that they have better security or perform more verification on their customers or similar, but the whole CA infrastructure is only really as strong as its weakest link, so that doesn't provide much benefit even if it's true.)

Update: The one major exception, as Brian points out, is that a certificate from Symantec / VeriSign in particular is required for features like Windows Error Reporting and Windows Hardware Certification, so if you want to use those features, you might as well buy VeriSign.  (This is discussed further on Stack Overflow.)

Once you get your certificate:

If necessary, run inf2cat to create or update your .cat file from your driver's .inf file.

Run signtool signwizard (for the GUI mode) or signtool with the appropriate command-line arguments to sign the .cat file.

inf2cat is part of the Windows Driver Kit (WDK).  signtool comes with the Platform SDK and the WDK.

The following web sites were useful to me when I was working on driver signing:

https://knowledge.verisign.com/support/code-signing-support/index?page=content&id=AR190

http://msdn.microsoft.com/en-us/windows/hardware/gg487328.aspx

http://msdn.microsoft.com/en-us/library/ff544865%28v=vs.85%29.aspx

Title: Windows driver signing


问:
How can I  really master a programming language?
I know that learning a language, you can simply buy a book, follow the examples, and whenever possible try the exercises. But what I'm really looking is how to master the language once you've learned it.

Now I know that experience is one major factor, but what about learning the internals of the language, what is the underlying structure, etc.

There are articles out there saying read this book, read that book, make this game and that game.
But to me this doesn't mean to master a language. I want to be able to read other people's code and understand it, no matter how hard that is. To understand when to use a function and when another, etc etc.

The list could go on and on but I believe I've made the point. :)

And finally, take whatever language as an example if needed, though best would be if C was taken as an example.

答:
10,000 hours of practice is what it takes.

Read "Teach Yourself Programming in Ten Years"

Key points from above:

Get interested in programming, and do some because it is fun. Make sure that it keeps being enough fun so that you will be willing
  to put in your ten years/10,000 hours.

Program. The best kind of learning is learning by doing.

Talk with other programmers; read other programs.


答:
This really depends on the size and variety of your scripts. If every page on your site needs most of the scripts, combine and minify. However if alot of your scripts are specific to pages and not global, then using a dependency loader like requirejs or headjs will have value. Especially for mobile devices that.

It has been my experience that this is more of a personal preference though. Use the one that you are most comfortable with. The performance issue is minimal compared to your personal enjoyment of managing the code.

Title: Is script grouping and minification counter-productive?

Body:
On a web page I have 1 script tag that contains all my minified JavaScript (I use SquishIt for .NET).

However I see that a few people prefer to load their scripts in parallel using something like requirejs or headjs.

I was wondering which is better for performance and whether combining and minifying all my JavaScript is worth the effort?


答:
You already know the answer to this

You have to use the language. A lot. To solve as diverse a range of problems as possible

You have to read (and, ideally, work with) other peoples code, preferably ones who have a degree of mastery (i.e. a deep understanding of at least some aspect of the language). By extension, if you can talk to people about solving problems with the language then so much the better.

It comes down to hard work and determination and for all that you may never get there.

Think of where we get the term from - to become a Master Craftsman you had to be an apprentice and then a journeyman and only them might you have the chance to become a master. Along the way you would be taught and you would practice and you would observe and question others at their craft and (hopefully) learn from them.

There's no magic bullet...

Title: How can I  really master a programming language?

Body:
I know that learning a language, you can simply buy a book, follow the examples, and whenever possible try the exercises. But what I'm really looking is how to master the language once you've learned it.

Now I know that experience is one major factor, but what about learning the internals of the language, what is the underlying structure, etc.

There are articles out there saying read this book, read that book, make this game and that game.
But to me this doesn't mean to master a language. I want to be able to read other people's code and understand it, no matter how hard that is. To understand when to use a function and when another, etc etc.

The list could go on and on but I believe I've made the point. :)

And finally, take whatever language as an example if needed, though best would be if C was taken as an example.


答:
I have to answer, "All of the above."  People argue about whether coding is an art, a craft, an engineering discipline, or a branch of mathematics, and I think it's fairest to say it's some of each.  As such, the more techniques you bring to mastery of the language, the better.  Here is a partial list:

Use the language all day, every day.  Usually this means being full-time employed in the language.

Read all you can about the language.  Especially, "best practices" and idioms.

Join a users group to talk with others about the language and what they do with it.

Work with other people's code!  There is no faster way to learn what not to do in a language than to have to clean up after someone who did something awful.

Support the code you write - every bug becomes a tour of your worst decisions!

Study computer science and languages in general

Learn a very different language.  A great compliment to C would be a functional language like Lisp.  This will turn the way you think about your procedural language inside out.

Learn to use the frameworks and APIs available for that language.

Take the time to do your own experiments with the language.  SICP is not applicable to C, but the attitude of learning a language by testing its limits is a very productive one.

Read the history of the language to learn why it was made the way it is.

Attend conferences to hear the language authors speak, or to hear what industry leaders are doing with the language.

Take a class in the language.

Teach the language to others (thanks to Bryan Oakley)

In summary, do everything you can think of.  There is no way to know everything about most languages.  Every learning technique you use brings an additional perspective to your understanding.


答:
There is no substitute for experience. In order to master something, you have to do/use it, at lot, for many different things.

So go ahead and use that language for exercises (like Project Euler) and personal projects, stuff you actually need, or stuff you just think is interesting. Write a game, write a webapp, write a parser, whatever you like. And at every step, strive to understand what you're doing rather than just pasting together code or following instructions.

I want to be able to read other people's code and understand it, no matter how hard that is.

That is something you can do right away once you've understood the basic syntax. Just take some code and take the time to figue it out in detail. Look up stuff you don't understand, or ask specific questions on places like Stack Overflow.


答:
Start by reading and understanding what is SDLC (aka, Software development life-cycle) . It is an iterative process that involves self-improvement, learning, **practicing, practicing...**

That would open your horizons on what areas do you need to learn or improve. There are several core software engineering books that you would also find very useful to read once you build couple of applications on your own.

In addition, once you would feel confident with an OOP language, you may start learning design patterns, and Head First Design patterns is really good book to consider. I love this book.


问:
Single statement if block - braces or no?
Which is better/more generally accepted?

This:

```<code>if(condition)
{
  statement;
}
</code>```

Or:

```<code>if(condition)
  statement;
</code>```

I tend to prefer the first one, because I think it makes it easier to tell what actually belongs in the if block, it saves others from adding the braces later (or creating a bug by forgetting to), and it makes all your if statements uniform instead of some with braces and some without.  The second one, however, is still syntactically correct and definitely more compact.  I'm curious to see which is more generally preferred by others though.

答:
I almost always use the brackets just to be on the safe side. However, sometimes if the contents of the block are really short I'll do leave them off and make it a one-liner like so:</p>

```<code>if (x==5) Console.WriteLine("It's a five!");
</code>```

Body:
I almost always use the brackets just to be on the safe side. However, sometimes if the contents of the block are really short I'll do leave them off and make it a one-liner like so:

if (x==5) Console.WriteLine("It's a five!");


答:
Ok, every recruiter from a tech company says the same thing before you're interview:

Study up on algorithms, as they will ask you about that during the
  interview.

Since you've basically quoted that sentence verbatum, I'm going to make the not-so-outlandish-guess that you're interviewing for a major tech company (whether it is Google, Microsoft, Apple, Amazon, or what not--they all do the same thing to their candidates).

You need books that focus on the algorithms they will quiz you on during the interview, as this will give you a better idea of what to expect. My recommendations:

http://www.amazon.com/Programming-Interviews-Exposed-Secrets-Programmer/dp/047012167X/ref=sr_1_2?s=books&ie=UTF8&qid=1348063912&sr=1-2&keywords=coding+interview

And

http://www.amazon.com/Cracking-Coding-Interview-Programming-Questions/dp/098478280X

I highly recommend that you read these books, especially the first one (wink, wink, nudge, nudge, cough--Imightbetalkingfromexperience--cough ).

In all seriousness though, a programming interview at a major tech company is nothing like interviews everywhere else. You need to be prepared for it because you're going up against people who have been preparing for months.

Read the books, practice writing code on paper, and knock it out of the park :)


问:
How do Programmers in the East see programmers in the West?
The other half of this question: How do programmers in the West see programmers in the East?

I think it's just as interesting and important to see how programmers in the east view programmers in the west.

The eastern part of the world (India/China/Philippines ) is often seen as mainly providing outsourcing services to the western world (USA and Europe).

Do you have the experience of working as part of an offshore team? If yes, how was it?

Do you hold any generalized ideas or opinions about the programmers from the West (e.g. Are they cooperative, do they deliver on time or do they do quality work?)

答:
I am a programmer from India. I have worked with native software houses having nothing to do with the West as well as large Indian outsourcing companies and US based software development firms.

Most of my understanding of computer science can be contributed to the sources from the West. Also, as I grew up (in a major metropolitan area), the influence of western media was increasing. So, I am mostly familiar with US culture as well as professional practices. And most of the people I studied with have had a similar exposure. With the exception being, about 95% of them have already migrated to the US. I have not.

On / off work, I have learnt a lot from American programmers, authors and computer scientists. Due to the Internet, the boundaries are disappearing fast for the learning oriented.

I appreciate the fact that the folks from the West put a lot of time and effort into sharing information on blogs, wikipedia, stackexchange, etc. This culture of knowledge sharing is something East has to relearn. I say "relearn" because, in spite of a rich heritage of excellent mathematical, scientific and spiritual knowledge, India has fallen way behind.

I personally treat programming as part of my personality and try to practice it as an art form. These are the traits I have picked up from the western people. Unfortunately, I find it hard to find such people here in India. Although, in recent years, I have noticed a geek culture rising, mostly in the field of web development.

Some negative aspects about the West need a mention. While working with them in a business setting with onsite-offshore model, people often come off as insecure. I think it is mostly due to the fear of being redundant. Many times, they are unwilling to share critical information or don't allow someone from India to work on important parts of code. This really bites. With a well established tech culture, financial stability and ample opportunities in the West, it seems to be an unnecessary fear.

Also, most of the technologies developed in the West, although extremely efficient and latest, strikes sometimes as dry. They have an inherent sameness, that makes almost every framework / stack / technology very predictable. What I rarely see is a wholesome software developed with a certain taste over longer periods of time, like Linux kernel or the C++ standard.


答:
If you just want to be allowed to install a driver on a windows machine, your CA use shouldn't matter (unless the CA isn't trusted by Microsoft).

However, only VeriSign certificates are supported as a means of identifying your organization to Microsoft for features like Windows Error Reporting and Windows Hardware Certification.  E.g., the Manage Your Digital Certificates page explicitly states to buy your certificate from VeriSign.

If you plan to make use of such functionality, you should buy a VeriSign certificate now rather than another certificate now and a VeriSign certificate later.

Title: Windows driver signing

Body:
My company is developing driver for our hardware. Now I need to sign my driver for 32 and 64 bit platforms.

Please tell, now I need to buy Authenticode certificate, right?

What CA to use?

DigiCert?

GlobalSign? ( http://www.sslshopper.com/microsoft-authenticode-certificates.html )

Symantec? ( http://www.symantec.com/verisign/code-signing/microsoft-authenticode )

What is the difference between this CA offers?

I need to use tools from WDK?


答: Try using the language for something it wasn't intended to be used for.  Write a device driver in Python, or a matrix manipulation library in COBOL.  I think one of the best ways to master a language is to really push it, trying to make its strengths overcome its weaknesses.</p>


问:
Bug Tracking Etiquette - Necromancy or Duplicate?
I came across a really old (2+ years) feature request issue in a bug tracker for an open source project that was marked as "resolved (won't fix)" due to the lack of tools required to make the requested enhancement. In the time elapsed since that determination was made, new tools have been developed that would allow it to be resolved, and I'd like to bring that to the attention of the community for that application.

However, I'm not sure as to what the generally accepted etiquette is for bug tracking in cases like this. Obviously, if the system explicitly states to not duplicate and will actively mark new items as duplicates (much in the way the SE sites do), then the answer would be to follow what the system says. But what about when the system doesn't explicitly say that, or a new user can't easily find a place that says with the system's preference is? Is it generally considered better to err on the side of duplication or necromancy? Does this differ depending on whether it's a bug or a feature request?

答:
What I'd do (and have done in the past) is create a new bug (to give it relevance), note the possible/new fix, and link to the old one for historical reference/tracking.

it also depends on the bug... that bug might be a "feature" now, or have well-established work-arounds that people have been using for 2 years that would be broken by a fix.

Basically, you really have to dig through and investigate the bug and potential fix, and if you still think it should be fixed, then log the bug.


答:
Perhaps you could open up a new bug report and link it to the old one. Justify your reasons for wanting to fix it. It could be the case that the fix would break existing behaviour (either binary compatibility or change the way they have to work with the applicaion) and fixing it could cause more problems than it's worth. If the fix would have minimal impact then there may be no objections to it being fixed.

You need to see exactly why it was decided to not fix in the first place.

Title: Bug Tracking Etiquette - Necromancy or Duplicate?

Body:
I came across a really old (2+ years) feature request issue in a bug tracker for an open source project that was marked as "resolved (won't fix)" due to the lack of tools required to make the requested enhancement. In the time elapsed since that determination was made, new tools have been developed that would allow it to be resolved, and I'd like to bring that to the attention of the community for that application.

However, I'm not sure as to what the generally accepted etiquette is for bug tracking in cases like this. Obviously, if the system explicitly states to not duplicate and will actively mark new items as duplicates (much in the way the SE sites do), then the answer would be to follow what the system says. But what about when the system doesn't explicitly say that, or a new user can't easily find a place that says with the system's preference is? Is it generally considered better to err on the side of duplication or necromancy? Does this differ depending on whether it's a bug or a feature request?


答:
The only thing that can adequately answer this is your organization's process. If this situation isn't defined, it should be defined so that it is consistent every time it happens.

I'd recommend reopening the old one and adding new information to it as appropriate. From a measurements/metrics perspective, this would probably be the least harmful - the new thing is not a new defect or enhancement, but rather revisiting an old one. There should be some state for incoming change requests that indicates it needs to be reviewed by whoever the responsible party is. By changing the state back to this, they can see the history (the fact it was deferred once before) but also the new information easily.


答:
NEVER consider yourself the master of the whole language until you have implemented a better language than that. Which means, to learn how a particular language works from beneath, get a book that teaches you the compiler/interpreter concepts of the language. For example:

C: The LCC Compiler book

C++: The Design and Evolution of C++(And then go on build your own
C++ compiler or atleast understand the implementation of one using
the GNU C++ Compiler code)

Java: Get "Inside JVM" and get the javac source code. "java"'s .C
code is also helpful

Python: CPython implementation.

ObjectiveC: Almost any material from Apple about the internals of ObjC runtime env and compiler source codes is going to help you.

Lisp: SICP Book (teaches you Scheme and a basic interpreter-compiler for lisp like language)
: Lisp in Small Pieces(another good book).


答:
This seems to me to be a common problem.  Old habits being what they are, it is not easy to overcome the tendency of experienced managers to manage people and, all too frequently, problems as well!

However, a Scrum team is a (or would ideally be) a self organising team, and a peer group.  If the new guy has tasks to complete from the backlog he has to be integrated into the team.  To be effective and accepted he/she has to behave as a team player.  And the team has to give him the opportunity to do so.

If the new guy still has line manager responsibilities, even if these involve other team members, then he must conduct these outside the team environment and “team space”.  Joining a Scrum team does not isolate people from the day to day necessities of corporate life and no-one should expect that it will.  Corporate life goes on!  But you do not need a team member who starts the manage the team.  The team manages itself and the journey to the goal too!

Lose the job title when participating within the team, and as advised above, get the guy some Scrum training (if he hasn’t had any), explain the ways of working, hold a team event to give everyone the opportunity to bond, and give the new team a chance.  I think you may find that this former line manager has skills that the team can benefit from, and not just technical ones.


问:
Good Practices for development team in large projects
Since I started learning C a few years ago, I have never been a part of a team that worked on a project. I am very interested to know what are the best practices for writing large projects in C.

One of the things I want to know, is when (not how) do I split my project into different source files?  My previous experience is with writing a header-source duo (the functions defined in the header are written in the source).

I want to know what are the best practices for splitting a project, and some pointers on important things when writing a project as part of a team?

答:
One of the most important things beside coding guidelines, versioning control systems, workflows and a lot of coffee is:

Communication.

You and your team members have to communicate with each other. Regardless if the question might be stupid, ask if in doubt. Talk if in doubt. Talk if not in doubt. Talk, talk, talk.

Having function prototypes and data structures in your header and the code in the source file is always a good idea. For even more structure you could split some aspects of your projects in subprojects (if desired).

And of course a bugtracker and ticket systems like Redmine or Bugzilla is highly recommended.


答: I'll make it easy on you. You'll never master a language. Period. If you think you have, then you very obviously have not. There's no mountain top you suddenly reach and say "Well, now, I've fully mastered that language. What now?" Even seasoned programmers who've been working with the same language for decades will tell you that sometimes they still run across new ideas, processes, practices, etc. The true goal is to master your conceptual understanding of a language or languages. The ability to learn new concepts and the speed with which you can adopt new or changed features in the language is far more important than rote knowledge of every keyword and syntax. Stop worrying about "mastering" a language, and simply worry about continually improving and refining the quality and efficiency of your code. That's what "masters" do.</p>


答:
May I make a couple of suggestions?

First if you can find a mentor to discuss your use of the language with, and to get the best tips and tricks, and to answer when one technique is better than another.

Secondly, practice as much as possible and try the language out to the max!  I used to work in a team, that would (as a matter of fun) pick out a verb or other piece of the programming language from the manual each day. It was a mark of honour if you could work it into your coding that day.  This meant the whole programming team needed to look at and understand the (sometimes) obscure term in order to understand and use it effectively.  Some days we failed, but that team was fun to work in and really technically switched on!!


问:
When is using stdio preferable to fstream?
I work on a well-established, embedded C++ code base.  We have been using a proprietary API to our filesystem.  For better integration with third-party C libraries, we are currently in the process of implementing most of stdio.h and fcntl.h.  I made what I thought was a non-controversial proposal that we should also implement the fstream class and encourage new C++ code to use it instead of the new (to our code base) C-style API.  We already have the stdout parts of iostream available, although it is not widely used.

Given a choice between using stdio and fstream, what are good reasons to choose stdio for embedded software development in C++?

答:
IF the classes are already implemented for fstream(including the operator overloading and the likes), then I would certainly use fstream(seems like more C++ programmers in the team). BUT If i were to implement the libraries myself(which is usually the case with MOST embedded system programmers) I would choose a faster efficient library like stdio. stdio is less dependent on the 'std-runtime-of-c' and more dependent on buffers and pointers to structures, which is obviously faster(to use and to code as well)!

stdio takes less space(hence executes faster) compared to fstream(which relies on oo concepts and branches off into ifstream and ofstream, above fstream there is a stream class).


答:
This is how I code in C(be it solo or in a group):

```<code>step 1. Understand the project
step 2. break the project into modules(each module has a separate folder)
step 3. break the modules into sub-modules(each sub-module is a .c/.h file pair)
step 4. write a manually desined "make" script. This step sounds ridiculous but it helps. Trust me.
step 5. learn to use a version control system
step 6. test-modify-debug-release. Release early and release often
step 7. think of improvements to the existing code
step 8. go back to the drawing board.
</code>```

For example(very crude, off the top of my head example):

```<code>You're designing an elevator simulation program.
STEP1: Understand. [we got floors, floors can have people, people press buttons.. etc]
MODULES:
      AI-Module[double-elevator single switch requires AI algos to decide which request is going to be addressed first and which elevator will service the request, depending upon the current position of both elevators]
     Interior-Electronics Module[To handle inter-elevator requests]
     Exterior-Electronics Module[To handle external-elevator requests]
     Human-Simulator Module[To simulate humans inside/outside the elevator(required to check overload)]

SUB_MODULES:
     AI-Module/ai.c, AI-Module/ai.h, AI-Module/decision_engine.c, AI-MODULE/decision_engine.h
     Interior-Electronics/press_button.c,Interior-Electronics/press_button.h, Interior-Electronics/delegates.c, Interior-Electronics/delegates.h
     Exterior-Electronics/press_button.c,Exterior-Electronics/press_button.h, Exterior-Electronics/delegates.c, Exterior-Electronics/delegates.h
     Human-Simulator/human_sim.c, Human-Simulator/human_sim.h
     ./manager.c ./manager.h ./main.c
</code>```

And the steps follow :-)

Title: Good Practices for development team in large projects

Body:
Since I started learning C a few years ago, I have never been a part of a team that worked on a project. I am very interested to know what are the best practices for writing large projects in C.

One of the things I want to know, is when (not how) do I split my project into different source files?  My previous experience is with writing a header-source duo (the functions defined in the header are written in the source).

I want to know what are the best practices for splitting a project, and some pointers on important things when writing a project as part of a team?

Body:
This is how I code in C(be it solo or in a group):

step 1. Understand the project
step 2. break the project into modules(each module has a separate folder)
step 3. break the modules into sub-modules(each sub-module is a .c/.h file pair)
step 4. write a manually desined "make" script. This step sounds ridiculous but it helps. Trust me.
step 5. learn to use a version control system
step 6. test-modify-debug-release. Release early and release often
step 7. think of improvements to the existing code
step 8. go back to the drawing board.

For example(very crude, off the top of my head example):

You're designing an elevator simulation program.
STEP1: Understand. [we got floors, floors can have people, people press buttons.. etc]
MODULES:
      AI-Module[double-elevator single switch requires AI algos to decide which request is going to be addressed first and which elevator will service the request, depending upon the current position of both elevators]
     Interior-Electronics Module[To handle inter-elevator requests]
     Exterior-Electronics Module[To handle external-elevator requests]
     Human-Simulator Module[To simulate humans inside/outside the elevator(required to check overload)]

SUB_MODULES:
     AI-Module/ai.c, AI-Module/ai.h, AI-Module/decision_engine.c, AI-MODULE/decision_engine.h
     Interior-Electronics/press_button.c,Interior-Electronics/press_button.h, Interior-Electronics/delegates.c, Interior-Electronics/delegates.h
     Exterior-Electronics/press_button.c,Exterior-Electronics/press_button.h, Exterior-Electronics/delegates.c, Exterior-Electronics/delegates.h
     Human-Simulator/human_sim.c, Human-Simulator/human_sim.h
     ./manager.c ./manager.h ./main.c

And the steps follow :-)


问:
What are the most popular IDEs per language?
This has nothing to do with having a favourite editor or anything like that. I was just wondering, per language, what are the most popular Integrated Development Environments? Maybe a top 2-3 if there is some contention. (Perceived popularity is enough)

Thus Far:

C# - Visual Studio, SharpDevelop

Java - Eclipse, NetBeans, IDEA

Objective-C - Xcode

Delphi - RAD Studio

Object Pascal - Delphi, Lazarus

C, C++ - Visual Studio, Vim

PL/SQL - RapidSQL, Oracle SQLDeveloper

PHP - Eclipse, NetBeans, Nusphere PHPed

Actionscript (AS2, AS3) - FlashDevelop

Flex - Flash Builder 4

Python - Eclipse, IDLE

Perl - Padre

Common Lisp - Lispworks, Emacs

Ruby - TextMate

Haskell - Vim

Fortran - Vim

Visual Basic - Visual Studio

答: For both Perl and Python: Emacs and Vim. Beats Eclipse in terms of popularity.


问:
Can DVCSs enforce a specific workflow?
So, I have this little debate at work where some of my colleagues (which are actually in charge of administrating our Perforce instance) say that workflows are strictly a process thing, and that the tools that we use (in this case, the version control system) have no take on it. In otherwords, the point that they make is that workflows (and their execution) are tool-agnostic.

My take on this is that DVCSs are better at encouraging people in more flexible and well-defined ways, because of the inherent branching occurring in the background (anonymous branches), and that you can enforce workflows through the deployment model you establish (e.g. pull requests through repository management, dictator/liutenant roles with their machines setup as servers, etc.)

I think in CVCSs you have to enforce workflows through policies and policing, because there is only one way to share the code, while in DVCSs you just go with the flow based on the infrastructure/permissions that were setup for you.

Even when I have provided the earlier arguments, I'm still unable to fully convince them. Am I saying something the wrong way?, if not, what other arguments or examples do you think would be useful to convince them?

Edit: The main workflow we have been focusing on, because it makes sense to both sides is the Dictator/Lieutenants workflow:

My argument for this particular workflow is that there is no pipeline in a CVCS (because there is just sharing work in a centralized way), whereas there is an actual pipeline in DVCSs depending on how you deploy read/write permissions.

Their argument is that this workflow can be done through branching, and while they do this in some projects (due to policy/policing) in other projects they forbid developers from creating branches.

答:
It's not terribly difficult to set up a pull request flow on a CVCS, it's just that no one does because they don't want to manage a gazillion personal branches on the server.  Perforce is one of the rare CVCS vendors trying to address this by introducing features like streams and sandbox.

There is one way DVCS distinguishes itself.  It gives you more control over your local workflow.  One scrum team can use a dictator/lieutenant model and another can use a single centralized server model, but when they send their code upstream the company as a whole can have an entirely different workflow.  Rather than saying DVCS makes it easier to "enforce a specific workflow," I would say it makes it easier to enforce a specific global workflow without imposing a specific local workflow.

Title: Can DVCSs enforce a specific workflow?


答:
You need a certificate which satisfies the kernel mode code signing policy (KMCS).

Here is a MSDN list of possible certificate authorities.

BUT, it seems WHQL (or how it is currently called) needs a Verisign certificate to allow you participation in the WHQL program for windows logo ... things .... So I would buy a Verisign certificate if a windows logo is needed in the future.

Title: Windows driver signing

OwnerDisplayName: Christopher


问:
Copy-and-Pasted Test Code: How Bad is This?
My current job is mostly writing GUI test code for various applications that we work on. However, I find that I tend to copy and paste a lot of code within tests. The reason for this is that the areas I'm testing tend to be similar enough to need repetition but not quite similar enough to encapsulate code into methods or objects. I find that when I try to use classes or methods more extensively, tests become more cumbersome to maintain and sometimes outright difficult to write in the first place.

Instead, I usually copy a big chunk of test code from one section and paste it to another, and make any minor changes I need. I don't use more structured ways of coding, such as using more OO-principles or functions.

Do other coders feel this way when writing test code? Obviously I want to follow DRY and YAGNI principles, but I find that test code (automated test code for GUI testing anyway) can make these principles tough to follow. Or do I just need more coding practice and a better overall system of doing things?

EDIT: The tool I'm using is SilkTest, which is in a proprietary language called 4Test. As well, these tests are mostly for Windows desktop applications, but I also have tested web apps using this setup as well.

答:
I used to agree with you. But then, over time, I found that every change I made (particularly DI changes in unit tests) required numerous tests to change and that was cumbersome. Now I subscribe to the school of DRY, even when writing tests.

For GUI testing, you may want to look at the PageObject pattern to reduce repeated code.


答:
It's still pretty bad to cut and paste.  There are a few problems.

Your tests may well be brittle, because you are vulnerable to something that requires a change in all that copy-and-pasted code.  Will you have to rewrite all the tests?

If you can't encapsulate the logic into helper methods outside your tests, you can't write tests of those helper methods themselves.  Writing tests of test methods is usually to hard to make worthwhile, since you have to break your code to test the test.  But you can unit test helper methods.

It may well make the tests less readable.  A big block of copied code may be harder to read than a call to helper method with a descriptive name.

Everything I've listed is something that may be a problem.  If you find none of them actually are a problem then of course it's fine.

Title: Copy-and-Pasted Test Code: How Bad is This?

Body:
My current job is mostly writing GUI test code for various applications that we work on. However, I find that I tend to copy and paste a lot of code within tests. The reason for this is that the areas I'm testing tend to be similar enough to need repetition but not quite similar enough to encapsulate code into methods or objects. I find that when I try to use classes or methods more extensively, tests become more cumbersome to maintain and sometimes outright difficult to write in the first place.

Instead, I usually copy a big chunk of test code from one section and paste it to another, and make any minor changes I need. I don't use more structured ways of coding, such as using more OO-principles or functions.

Do other coders feel this way when writing test code? Obviously I want to follow DRY and YAGNI principles, but I find that test code (automated test code for GUI testing anyway) can make these principles tough to follow. Or do I just need more coding practice and a better overall system of doing things?

EDIT: The tool I'm using is SilkTest, which is in a proprietary language called 4Test. As well, these tests are mostly for Windows desktop applications, but I also have tested web apps using this setup as well.


答:
Copy-pasted and then edited test cases are often fine.

Tests should have as few external dependencies as possible, and be as straightforward as possible. Test cases tend to change with time, and previously almost identical test cases may suddenly diverge. Updating one test case without having to worry about breaking other cases is a Good Thing.

Of course, boilerplate code which is identical in many test cases and has to change in concert can and should be factored out.


答:
Since you're asking about the API, there's not much to say other than the classic <iostream> vs <stdio.h> arguments.  While many of these sort of arguments are just subjective matters of taste, it seems clear to me that there are many objective reasons that make iostream vastly preferable.  IOstream provides you with type-safety and extensibility, and avoids the possibility of leaving you open to a format string security exploit.

I see no particular reason why this should be much different in an embedded environment.  I would go with <iostream>.

The only (somewhat contrived) reason I can see to favor stdio.h in a C++ project is if you are working with a C API that often uses varargs, forcing you to frequently use v*printf functions.  In that case, you could argue that it might be better to stick with stdio.h just for the sake of consistency throughout the code.

Title: When is using stdio preferable to fstream?

Body:
I work on a well-established, embedded C++ code base.  We have been using a proprietary API to our filesystem.  For better integration with third-party C libraries, we are currently in the process of implementing most of stdio.h and fcntl.h.  I made what I thought was a non-controversial proposal that we should also implement the fstream class and encourage new C++ code to use it instead of the new (to our code base) C-style API.  We already have the stdout parts of iostream available, although it is not widely used.

Given a choice between using stdio and fstream, what are good reasons to choose stdio for embedded software development in C++?


答:
I'd use the following (the consensus here):

```<code>if (condition) {
    any_number_of_statements;
}
</code>```

Also possible:

```<code>if(condition) single_compact_statement;
</code>```

Not so good, especially in C/C++-like languages:

```<code>if(condition)
    single_compact_statement;
</code>```

(No choice here in Python ;-)

In Perl, you'd use:

```<code>$C = $A**3 if $A != $B;
</code>```

or

```<code>$C = $A**3 unless $A == $B;
</code>```

(This is not pseudocode ;-)

Body:
I'd use the following (the consensus here):

if (condition) {
    any_number_of_statements;
}

Also possible:

if(condition) single_compact_statement;

Not so good, especially in C/C++-like languages:

if(condition)
    single_compact_statement;

(No choice here in Python ;-)

In Perl, you'd use:

$C = $A**3 if $A != $B;

or

$C = $A**3 unless $A == $B;

(This is not pseudocode ;-)


答:
My top reason would be familiarity with the library. Back in my embedded days (a little over a decade ago), most C++ developers in several companies where I worked came from a strong C background. C-style input and output did not require any learning, while dealing with advanced concepts of manipulating streams often required checking a book.

As far as purely technical reasons go, I don't think there are any: properly implemented stream I/O should be as fast as the C-style I/O, and use roughly the same amount of memory.


答:
I would recommend picking up XUnit patterns. I used to have the exact same problem until I started leveraging that book. The Object Mother pattern sounds like it would be the most helpful for your scenario.

Like someone else mentioned, properly encapsulating this setup code might be onerous, but having to change it in all the places you copy and pasted is even more so.


答:
Repetition is the root of all evil

That is right! Repetition is the root of all evil. Probably it was Knuth saying in his book “Premature optimization is the root of all evil”, but I think it’s repetition.

Whenever you look at a program or you’re writing one and you discover some kind of repetition: Remove it! Kill it immediately… whatever but get rid of it!

Each time I introduced some sort of repetition and had to fix a bug in there, I forgot to fix the replica...(Donald Knuth) So, whenever there is a repetition just remove it as best as you can, don’t hack!

Think of a clean lean design (like, encapsulating your repeating code blocks in helper classes) and write some tests before changing something (just to be sure you didn’t break something). This is true for any piece of code that is written and test codes are no exception.

Here is a good reading from Code Horror that inspires me - A Modest Proposal for the Copy and Paste School of Code Reuse.


问:
Why would one bother marking up properly and semantically?

Note that I (try) to mark up as semantically as possible because I like they way it looks and feels, but not because I'm aware of any other stunning advantages. The point of my question is to be able to educate others

Well, I've seen a lot of articles and tutorials which often state "Let's mark this up in the most semantic possible way".

But a strange thought came to me, why?

Why would one need (or want) to bother with the specific elements which convey the correct semantic meaning? Specifically, I'm referring to the new HTML5 elements, such as <time>, <output>, or <address>. Especially, if the page "works" (it renders nicely in all browsers).

Why would I want to use elements like <time> or <address>, where nothing at all (or at the worst case, a generic ) works just as nicely?

I'm asking this because I'm seeing a multitude of (very popular) websites (this one included) which does not follow these so-called best practices.

答: To add to the already good answers here, one thing I haven't seen mentioned is forward compatibility.  As the spec evolves it is possible that additional functionality be specified for certain semantic elements.  If your code is semantically correct it will be able to take advantage of this functionality with no, or minimal maintenance.


问:
Can I use new BSD licensed library/code in commercial closed source project?
I've found a software library, licensed under the new BSD license.

I want to use in my closed source commercial project. Can I do it?

答: Did you read the license? Because it's pretty short and I think easy to understand. Unless your lawyer tells you otherwise, I'd say that yes, you can use the code, but you have to put their notice & disclaimer in your documentation (about box, whatever).</p>

ContentLicense: CC BY-SA 4.0