答:
I would say that it isn't, and that your interpretation of the interface is incorrect.

HTTP isn't the interface that a web service exposes. A web service exposes a higher level interface, say, a set of REST endpoints or a SOAP contract, that is machine readable. Saying that a web service exposes an HTTP interface is like saying it exposes a TCP/IP interface - technically true, perhaps, but at a lower level, thus making it irrelevant.

A web application is a set of HTML tags, or rich content (Flash, etc), that is human readable. A human is needed to understand that clicking the "Contact Us" link leads to a contact form, and it is not machine-readable.

Title: Is Web application a Web service?

Body:
According to W3C:

Web service is a software system designed to support interoperable machine-to-machine interaction over a network. It has an interface described in a machine-processable format

Web application conforms to this definition. Its interface is HTTP.

So can web application be called web service?


问:
Why the bound of a linear function is same as that of a quadratic equation
I am learning algorithms, and I came across something very interesting.

The asymptotic bound of the linear equation (a * n)+b is O(n^2), for all a > 0.

This is same bound as a * n^2 + b * n + c, which is surprising.

答:
Roughly speaking any two functions can be bounded by the same bound. The thing we really care is whether the bound is tight or loose. any constant O(1), linear and quadratic functions can be surely bounded by O(n2), or O(n3), or O(n4), or O(en).

But considering a very loose bound really can't give much information about a function itself. Thus, in practice, we should always choose the tightest bound for a function. So usually, when we talk about the bound, it could implicitly be the tightest bound.

ContentLicense: CC BY-SA 3.0


答:
It is important to realize, that O(f) represents a set of functions, for which c*f is an asymptotic upper bound for some constant c.

Just like there is more than one number that is bigger than 1, there is not just a single function that qualifies as an asymptotic upper bound for a function.

The tightest bound for (a*n) + b) is O(n), but it is also in O(n^2), but that's being very generous, and doesn't provide as much information as saying it's in O(n), because that is a much stronger statement.

I suggest you take a look at this similar question for more information.

Title: Why the bound of a linear function is same as that of a quadratic equation

Body:
I am learning algorithms, and I came across something very interesting.

The asymptotic bound of the linear equation (a * n)+b is O(n^2), for all a > 0.

This is same bound as a * n^2 + b * n + c, which is surprising.


问:
Is throwing an exception from a property bad form?
I've always been of the mindset that properties (ie, their set/get operations) should be fast/immediate and failure-free. You should never have to try/catch around getting or setting a property.

But I'm looking at some ways to apply role-based security on the properties of some objects. For instance an Employee.Salary property. Some of the solutions I've run across that others have tried (one in particular is the AOP example here) involve throwing an exception if the accessor doesn't have the right permissions - but this goes against a personal rule that I've had for a long time now.

So I ask: am I wrong? Have things changed? Has it been accepted that properties should be able to throw exceptions?

答:
The point of a property is the Uniform Access Principle, i.e. that a value should be accessible through the same interface whether implemented by storage or computation.  If your property is throwing an exception that represents an error condition beyond the programmer's control, the kind that is supposed to be caught and handled, you are forcing your client to know that the value is obtained via computation.

On the other hand, I don't see any problem with using asserts or assertion-like exceptions that are meant to signal incorrect use of the API to the programmer rather than being caught and handled.  In these cases the correct answer from the API user's perspective isn't to handle the exception (thus implicitly caring about whether the value is obtained via computation or storage).  It's to fix his/her code so the object doesn't end up in an invalid state or make you fix your code so the assertion doesn't fire.

ContentLicense: CC BY-SA 2.5


问:
Naming a class that processes orders
I'm in the midst of refactoring a project. I've recently read Clean Code, and want to heed some of the advice within, with particular interest in Single Responsibility Principle (SRP).

Currently, there's a class called OrderProcessor in the context of a manufacturing product order system.

This class is currently performs the following routine every n minutes:

check database for newly submitted + unprocessed orders (via a Data Layer class already, phew!)

gather all the details of the orders

mark them as in-process

iterate through each to:

perform some integrity checking

call a web service on a 3rd party system to place the order

check status return value of the web service for success/fail

email somebody if web service returns fail

constantly log to a text file on each operation or possible fail point

I've started by breaking out this class into new classes like:

OrderService - poor name. This is the one that wakes up every n minutes

OrderGatherer - calls the DL to get the order from the database

OrderIterator (? seems too forced or poorly named) -

OrderPlacer - calls web service to place the order

EmailSender

Logger

I'm struggling to find good names for each class, and implementing SRP in a reasonable way.

How could this class be separated into new class with discrete responsibilities?

答:
As a general rule I have 1 class for every object (often linked to a DB table) or process.

It can sometimes be difficult to define all your classes ahead of time, so I tend to create some bare-bones classes and start writing a rough version (often procedural) of what I want to do.
This process of actually seeing how your code hangs together enables me to start spotting patterns and links. I can then quickly change my skeleton classes quickly, effectively creating the design and workflow iteratively until I arrive at something I'm happy with.

I'd start with:

OrderChecker - thread class that checks every n minutes

OrderProcessor - gets new order from DB (using DAL) and processes each one - this is where the bulk of the work will take place, including making calls to EmailSender and Logger.

OrderSender - Sends emails based on status of order (descended from generic email sender class)

OrderLogger - Logs info based on results of order processing (descended from generic logger class?)

I find the key is to keep everything fairly "loose" (often quick-and-dirty) until you're happy with your design and have accounted for all foreseeable issues/requirements.

Title: Naming a class that processes orders


问:
Collaboration between client, web designer, and web developer
I am primarily a Web Developer (back end programming) - but intend to offer a complete service to my clients, from concept, to brand design, photoshop mock-ups and everything else in between. I'm aware that it's a good idea to outsource this design aspect of the project to someone that I trust. My question is more about the process:

I imagine that in order for the designer to really grasp what the client wants to create, they would need some sort of interaction. Therefore, does anyone know if it is common to bring both parties into a 3 way discussion? Or is it more common to get all of the info from the client, and then pass it onto the designer, and act as a back and forth middleman? Afterall, I am the designer's client.

Any insight into this would be great

答:
You should act as the project manager on behalf of the client, gathering their requirements and managing their expectations, while passing as much information onto the designer as they need (it's especially important that the designer be someone you know/trust).

I may be inclined to take the designer to the kick-off meeting though this should be decided on a per-project basis.

Once work has started, I'd bring the designer along to a couple of meetings (dependant on the size of the project) so they can get a better feel for your client, this will probably more important as the design progresses and becomes more finalized.

There's always a certain amount of fluidity in these projects and some clients like to "tinker" with the design right up to the last minute, having the designer in the room can be a great help here.


答:
I know your question is specific to .NET, but since C# shares some history with Java, I thought you might be interested.  I am not in any way implying that because something is done in Java, it should be done in C#.  I know the two are very different, especially in how C# has much-improved language-level support for properties. I am just giving some context and perspective.

From the JavaBeans specification:

Constrained properties Sometimes when a property change occurs some
  other bean may wish to validate the
  change and reject it if it is
  inappropriate. We refer to properties
  that undergo this kind of checking as
  constrained properties. In Java Beans,
  constrained property setter methods
  are required to support the
  PropertyVetoException. This documents
  to the users of the constrained
  property that attempted updates may be
  vetoed. So a simple constrained
  property might look like:

```<code>PropertyType getFoo();
void setFoo(PropertyType value) throws PropertyVetoException;
</code>```

Take all this with a grain of salt, please.  The JavaBeans specification is old, and C# Properties are (IMO) a huge improvement over the "naming convention" based properties that Java has.  I'm just trying to give a little context, is all!

Title: Is throwing an exception from a property bad form?

Body:
I've always been of the mindset that properties (ie, their set/get operations) should be fast/immediate and failure-free. You should never have to try/catch around getting or setting a property.

But I'm looking at some ways to apply role-based security on the properties of some objects. For instance an Employee.Salary property. Some of the solutions I've run across that others have tried (one in particular is the AOP example here) involve throwing an exception if the accessor doesn't have the right permissions - but this goes against a personal rule that I've had for a long time now.

So I ask: am I wrong? Have things changed? Has it been accepted that properties should be able to throw exceptions?

Body:
I know your question is specific to .NET, but since C# shares some history with Java, I thought you might be interested.  I am not in any way implying that because something is done in Java, it should be done in C#.  I know the two are very different, especially in how C# has much-improved language-level support for properties. I am just giving some context and perspective.

From the JavaBeans specification:

Constrained properties Sometimes when a property change occurs some
  other bean may wish to validate the
  change and reject it if it is
  inappropriate. We refer to properties
  that undergo this kind of checking as
  constrained properties. In Java Beans,
  constrained property setter methods
  are required to support the
  PropertyVetoException. This documents
  to the users of the constrained
  property that attempted updates may be
  vetoed. So a simple constrained
  property might look like:

PropertyType getFoo();
void setFoo(PropertyType value) throws PropertyVetoException;

Take all this with a grain of salt, please.  The JavaBeans specification is old, and C# Properties are (IMO) a huge improvement over the "naming convention" based properties that Java has.  I'm just trying to give a little context, is all!


答:
Don't be a middle-man between your graphic designer and your client.  Be there for the first meetings between them.  Make the designer write up a summary of each meeting and send it to all three of you.  Once you know that the meetings are going well and that the summary is suitable to keep you informed, you can drop out and just read the summary emails.

You can join any meeting at any time if your designer and client need more management, either for scope, technical guidance, or other reasons.  Projects move slowly enough as it is.  The cost to everyone of "he said, she said" can be huge.

Maybe you double as an interior decorator, but even if you do, it's really hard to convey to your designer that your client wants more of a peach-blush background than a warm pink, then get back to the client that the designer thinks peach-blush will wash out the key-lime highlight in the logo, and that it will have to be changed to more of a spring-grass-green, etc.  Don't be the middle man any more than you have to be.

Title: Collaboration between client, web designer, and web developer

Body:
I am primarily a Web Developer (back end programming) - but intend to offer a complete service to my clients, from concept, to brand design, photoshop mock-ups and everything else in between. I'm aware that it's a good idea to outsource this design aspect of the project to someone that I trust. My question is more about the process:

I imagine that in order for the designer to really grasp what the client wants to create, they would need some sort of interaction. Therefore, does anyone know if it is common to bring both parties into a 3 way discussion? Or is it more common to get all of the info from the client, and then pass it onto the designer, and act as a back and forth middleman? Afterall, I am the designer's client.

Any insight into this would be great


问:
Should an object know its own ID?
obj.id seems fairly common and also seems to fall within the range of something an object could know about itself. I find myself asking why should my object know its own id?

It doesn't seem to have a reason to have it? One of the main reason for it existing is retrieve it, and so my repositories need to know it, and thus use it for database interaction.

I also once encountered a problem where I wanted to serialize an object to JSON for a RESTful API where the id did not seem to fit in the payload, but only the URI and including it in the object made that more difficult.

Should an object know it's own id? why or why not?

update:
Terms

id: Identifier attribute on an object. in database terms, a surrogate key not a natural key.

Object: an Entity, or otherwise uniquely identifiable object within the system.

答:
Short Answer: Including object identifier within the object is a must if it is going to be referred.

For a scenario where you are planning to use a collection of objects and have plans to refer an individual object/entity then identifier should be included. However, there might be cases where natural key/identifier like DateTime can artificially fulfill that need.

In addition, you may have your DTO's as a lightweight container of your object, that may skip/include object identifier in itself. Really all this choices are really depend on your business use cases and needs.

Edit: if you want to identify your object you need to have an identifier. That identifier can be a surrogate Id, date-time, guid, etc... basically, anything that identifies your object from others in a unique way.

Title: Should an object know its own ID?


答:
It's fairly common to include the ID, but it's also common to use dictionaries, i.e. the data structures where each object is associated with its ID in a way that you can easily retrieve this object knowing the corresponding ID, but the object doesn't know it.

For example, if you're creating an API with two methods:

http://api.example.com/products/

Loads the list of IDs of products.

http://api.example.com/product/452/

Loads a product of ID 452.

Then you don't need to resend the ID 452 in the JSON response of the second request. The user of the API already knows the ID.

Title: Should an object know its own ID?

Body:
obj.id seems fairly common and also seems to fall within the range of something an object could know about itself. I find myself asking why should my object know its own id?

It doesn't seem to have a reason to have it? One of the main reason for it existing is retrieve it, and so my repositories need to know it, and thus use it for database interaction.

I also once encountered a problem where I wanted to serialize an object to JSON for a RESTful API where the id did not seem to fit in the payload, but only the URI and including it in the object made that more difficult.

Should an object know it's own id? why or why not?

update:
Terms

id: Identifier attribute on an object. in database terms, a surrogate key not a natural key.

Object: an Entity, or otherwise uniquely identifiable object within the system.


问:
Help with DB Structure, vOD site
I have a video on demand style site that hosts series of videos under different modules.  However with the way I have designed the database it is proving to be very slow.  I have asked this question before and someone suggested indexing, but i cannot seem to get my head around it.  But I would like someone  to help with the structure of the database here to see if it can be improved.  The core table is Videos:

```<code>ID       bigint(20) (primary key, auto-increment)
pID      text
airdate  text
title    text
subject  mediumtext
url      mediumtext
mID      int(11)
vID      int(11)
sID      int(11)
</code>```

pID is a unique 5 digit string to each video that is a shorthand identifier.  Airdate is the TS, (stored in text format, right there maybe I should change that to TIMESTAMP AUTO UPDATE), title is self explanatory, subject is self explanatory, url is the hard link on the site to the video, mID is joined to another table for the module title, vID is joined to another table for the language of the video, (english, russian, etc) and sID is the summary for the module, a paragraph stored in an external database.

The slowest part of the website is the logging part of it.  I store the data in another table called 'Hits':

```<code>id      mediumint(10)   (primary key, auto-increment)
progID  text
ts      int(10)
</code>```

Again, here (this was all made a while ago) but my Timestamp (ts) is an INT instead of ON UPDATE CURRENT TIMESTAMP, which I guess it should be.  However This table is now 47,492 rows long and the script that I wrote to process it is very very slow, so slow in fact that it times out.  A row is added to this table each time a user clicks 'Play' on the website and then so the progID is the same as the pID, and it logs the php time() timestamp in ts.

Basically I load the entire database of 'Hits' into an array and count the hits in each day using the TS column.  I am guessing (i'm quite slow at all this, but I had no idea this would happen when I built the thing) that this is possibly the worst way to go about this.

So my questions are as follows:

Is there  a better way of structuring the 'Videos' table, is so, what do you suggest?

Is there a better way of structuring 'hits', if so, please help/tell me!

Or is it the fact that my tables are fine and the PHP coding is crappy?

答:
I can see a couple of things you should look at.

What is pID used for? If it's just to link the 2 tables an int will be a lot faster and simplify the videos table.

You're right, AirDate should be stored as a timestamp/datetime field, whenever possible you want to keep the text fields to the minimum required. I'd even consider moving title, subject (& a new description field) into a separate table (this keeps the main videos table as small and fast as possible):

```<code>ID bigint (same as videos.ID field)
title mediumtext
subject mediumtext
description mediumtext
</code>```

For the hits table, I'd do exactly as @Morons suggested, possibly with an additional table to log each play separately (if this is important):

```<code>ID bigint (same as videos.ID field)
playedat timestamp/datetime
playedby int (if userid is known) / text (IP address if videos can be played anonymously)
</code>```

@Morons suggestion will give the biggest speed increase though. As a basic rule, whenever possible, push as much data logic onto the DB server, it's what they're designed for and they're very good (fast) at it, also minimize the number of times you hit the DB and the amount of information you're transferring back over the network.

Title: Help with DB Structure, vOD site

Body:
I can see a couple of things you should look at.

What is pID used for? If it's just to link the 2 tables an int will be a lot faster and simplify the videos table.

You're right, AirDate should be stored as a timestamp/datetime field, whenever possible you want to keep the text fields to the minimum required. I'd even consider moving title, subject (& a new description field) into a separate table (this keeps the main videos table as small and fast as possible):

ID bigint (same as videos.ID field)
title mediumtext
subject mediumtext
description mediumtext

For the hits table, I'd do exactly as @Morons suggested, possibly with an additional table to log each play separately (if this is important):

ID bigint (same as videos.ID field)
playedat timestamp/datetime
playedby int (if userid is known) / text (IP address if videos can be played anonymously)

@Morons suggestion will give the biggest speed increase though. As a basic rule, whenever possible, push as much data logic onto the DB server, it's what they're designed for and they're very good (fast) at it, also minimize the number of times you hit the DB and the amount of information you're transferring back over the network.


答:
In an attempt to leave my answer as abstract as your question, I think you've actually answered your own question.

An object should know its own ID if it needs to.

An object shouldn't know its ID (or that it even has one) if it doesn't need to.

As you pointed out, there are cases where it is either inconvenient or unnecessary for the object to retain or know if its ID.  But there are other cases where it is more convenient for the object to be aware of its ID.  Code your objects as appropriate to their usage.

Title: Should an object know its own ID?


问:
What is the relevance of resumes in the age of GitHub, Stack Exchange, Coursera, Udacity, blogs, etc.?
My resume is no longer relevant. It can no longer contain an adequate description of my technical abilities. One can get a much better sense of what I am capable of by looking at my GitHub repositories, my Stack Exchange profiles, and the various courses that I am taking at Udacity and Coursera. The problem is that I have no idea how to tell employers that those are the places to look if they want an accurate description of what I can do.

Every time a recruiter contacts me I gently nudge them towards all the resources I just mentioned and I also provide a link to a publicly visible Google doc that contains my resume along with links to all those resources. Yet, they keep coming back asking for a more descriptive resume.

How can I make it even more blatantly obvious that if somebody wants to hire me then they can save themselves a whole bunch of trouble by just clicking on a few links and browsing around?

答: If GitHub and StackExchange are places online where you've achieve some level of notoriety and  importance, perhaps highlighting these as professional achievements or hobbies will do more IN your resume.</p>


答:
I think that this is subjective and depends on your design.

Mostly though this appears to be a design that comes from an active record. In an active record your entity has methods to do database operations and therefore must also know it's database identifier.

When using other patterns such as a repository with a data mapper storing this data in the object becomes unnecessary and perhaps inappropriate.

Take for example a Person object. I am given a name which may or may not be unique within a family. As the population has grown larger names are no longer unique and so we have come up with surrogate identifiers for increasingly large system. Examples of these include: my drivers license, and social security number. I am not born assigned an id, all of these id's must be applied for.

Most of these do not make good primary keys/ids for software, as they are not universal. At least not outside of their specific system, obviously an SSN is unique, and consistent, to the Social Security Administration. Since we are not generally the providers of this information you would not call them an id but rather the data they represent, e.g. SSN. Sometimes even contain the full composed object such as a DriversLicense which could contain all of the information the driver's license does.

All general id's are thus surrogate keys in the system, and could be replaced with in memory references, only containing id's to make looking up and persisting records easier.

Since an id is not a piece of conceptual data, I doubt that it (generally) belongs within the object, as it does not come from the domain. Rather it should be retained to its purpose which is to identify an object which has no other way to represent a unique identity. This could be done in a repository/collection with easy.

In software if you need to represent the object as a list, or persist it, you can simply do so from the repository/collection object, or some other object associated with that. When passing on to the Data Mapper (if it's separate), you can simply pass .update( id, obj ).

Disclaimer: I have not yet tried to build a system that does not contain the id within the entity and thus may prove myself wrong.

Title: Should an object know its own ID?


问:
Is having functionality in DB a road block to scalability?
I may not be able to give the right title to the question. But here it is,

We are developing financial portal for wealth management. We are expecting over 10000 clients to use the application. The portal calculates various performance analytics based on the the technical analysis of the stock market.

We developed lot of the functionality through Stored procedures, user defined functions, triggers etc. through Database. We thought we can gain huge performance boost doing stuff directly in database than through C# code. And we actually did get a huge performance boost.

When I tried to brag about the achievement to our CTO, he counter questioned my decision of having functionality implemented in database rather than code. According to him such applications suffer scalability problems. In his words "These days things are kept in memory/cache. Clustered data is hard to manage over time. Facebook, Google have nothing in database. It is the era of thin servers and thick clients. DB is used only to store plain data and functionality should be completely decoupled from the database."

Can you guys please give me some suggestions as to whether what he says is right. How to go about architect such an application?

答:
Scalability has nothing to do with where the data sits or how the computation happens. Scalability is all about how you manage global state and data inter-dependence. If your architecture is convoluted with all sorts of data inter-dependencies then it doesn't matter where you put the code for transforming that data. The inter-dependencies are going to force your hand and reduce any potential for scaling things. If on the other hand your data is loosely coupled and there is very little to no global state then once again it doesn't matter where the computation happens. Scaling things is going to be much easier.

I'm not sure where your CTO is getting his information about scalability issues but from what you have said it doesn't sound like he has any real reasons for questioning the current architectural decision other than software fashion trends. Basing architectural decisions on such trends is usually a bad idea.


答:
As GlenH7 noted in a comment, it's a good question, because it challenges what many people take for granted. My take on it however is that even if leaving the id out might seem conceptually pure, the pragmatic thing to do would be to keep the id with the object across as many layers of the system as possible. It costs little, but can come in handy when things start to break down.

An entity might not need to know it's id, just like a person doesn't need to know his personal identification number, driver license number nor any other identifier that might be in use in your location. You could certainly do without it most of the time. It's wise however to carry some kind of identification on you, just in case.

The same can be said of an object. Regardless of the data access layer's intricacies, the object ultimately maps to a certain database entry. This entry might only be uniquely identifiable by object's id. If so, then I would prefer to have this information available to me at any time, regardless whether I'm debugging some UI code, number crunching in the business layer, the repository itself or a dependent system across a webservice. Or whether I'm browsing error logs for that matter.

In your case, if you're only fetching data from the db and pushing it through the webservice, leaving the id out might be be the right thing to do. I just don't believe that it makes more sense than keeping it in the general case.

Title: Should an object know its own ID?


问:
Abstract class + Inheritance vs Interface
Hello fellow programmers,

I am reading a book on C# and the author is comparing Abstract classes and Interfaces. He claims that if you have the following "abstract class:"

```<code>abstract class CloneableType
{
public abstract object Clone();
}
</code>```

Then you cannot do this:

```<code>public class MiniVan : Car, CloneableType
{}
</code>```

This, I understand. However he claims that because of this inability to do multiple inheritance that you should use an interface for CloneableType, like so:

```<code>public interface ICloneable
{
object Clone();
}
</code>```

My question is, isn't this somewhat misleading, because you can create an abstract class which is "above" class Car with the method Clone, then have Car inherit that class and then Minivan will inherit Car with all these methods, CloneAble class -> Car class -> Minivan Class.

What do you think?
Thanks.

答:
Short Answer: Author is just emphasizing that a class may inherit only from one, and ONLY one Base class. However, it may have as many Interfaces as needed. This is true for C#, VB.NET languages.

However, you may have set of classes that inherit one from another. You may also build change inheritance, which should be carefully designed, and better to be avoided.

Long story short, interfaces are very handy to propagate common behaviors (actions like Create, Update, Delete, etc..) to classes.


答:
The difference between the abstract classes and interfaces in your case could allow the developer to well-define the pattern of your design with abstract class create "is a" relationship and interface create "can do" relationship.

Put it this way, if you have a Toy car and it would be not make sense to make them "is a" relationship with Minivan since you can use interface to exhibit toy car specific behaviour like water resistance tolerance.

So you can define like:

```<code>public Interface IToyCarResistance
{
  int ToleranceLevel { get; }
}

public class ToyCar : Car , IToyCarResistance
{
}
</code>```

Title: Abstract class + Inheritance vs Interface

Body:
Hello fellow programmers,

I am reading a book on C# and the author is comparing Abstract classes and Interfaces. He claims that if you have the following "abstract class:"

```<code>abstract class CloneableType
{
public abstract object Clone();
}
</code>```

Then you cannot do this:

```<code>public class MiniVan : Car, CloneableType
{}
</code>```

This, I understand. However he claims that because of this inability to do multiple inheritance that you should use an interface for CloneableType, like so:

```<code>public interface ICloneable
{
object Clone();
}
</code>```

My question is, isn't this somewhat misleading, because you can create an abstract class which is "above" class Car with the method Clone, then have Car inherit that class and then Minivan will inherit Car with all these methods, CloneAble class -> Car class -> Minivan Class.

What do you think?
Thanks.

Body:
The difference between the abstract classes and interfaces in your case could allow the developer to well-define the pattern of your design with abstract class create "is a" relationship and interface create "can do" relationship.

Put it this way, if you have a Toy car and it would be not make sense to make them "is a" relationship with Minivan since you can use interface to exhibit toy car specific behaviour like water resistance tolerance.

So you can define like:

public Interface IToyCarResistance
{
  int ToleranceLevel { get; }
}

public class ToyCar : Car , IToyCarResistance
{
}


答: The idea that the author is trying to emphasize is that designing an abstract class instead of an interface limits your ability to mix and match that class with other parts of your system later on. This is a tradeoff between an ability to share an implementation in exchange for inability to combine multiple abstract classes later on.</p>


问:
Are Java certifications important for an architect role?
I want to know how much Java Certifications (SCJP, SCWCD and others) are important for an architect position. If a person posses a good experience in Java development and want to pursue his career on architect level, do you guys think he need to have certification on his CV. If he has never worked on lead developer roles?

If you conducting my interview for an architect position. And I have worked as a Java web developer in different teams having 5 years of exp. Never lead any. And I am having certification badges on my CV.

How can a developer make his career path towards being an architect in a team?

答:
The international software architecture qualification board provides a vendor- and technology neutral curriculum (they don't sell courses or classes!), with focus on methodological and conceptual know-how.

Could, imho, complement any technology-centered certification.


问:
Is Learning C++ Through The Qt Framework Really Learning C++
The problem I have, is that most of the C++ books I read spend almost forever on syntax and the basics of the language, e.g. for and loops while, arrays, lists, pointers, etc.

But they never seem to build anything that is simple enough to use for learning, yet practical enough to get you to understand the philosophy and power of the language.

Then I stumbled upon QT which is an amazing library!

But working through the demos they have, it seems like I am now in the reverse dilemma. I feel like the rich man's son driving round in a sports car subsidized by the father. Like I could build fantastic software, but have no clue what's going on under the hood.

As an example of my dilemma take the task of building a simple web browser. In pure C++, I wouldn't even know where to start, yet with the Qt library it can be done within a few lines on code.

I am not complaining about this. I am just wondering how to fill the knowledge void between the basic structure of the language and the high level interface that the Qt framework provides?

答: It is a bad idea to learn C++ through Qt. First you have to learn the language concepts independant of any framework and that is what c++ books will teach you and they are right. Basically, 'for and loops while, arrays, lists, pointers' are what programming languages are all about. Additional functionalities  are provided by frameworks. Once you learn a programming language, you can learn any framework like Qt or MFC that is built using the language, so that applications can be developed quickly. Regarding Qt, once you learn c++, it is an excellent framework which makes you as productive as any Java or .Net developers. Shortly you will be able develop ios and Android apps using Qt.</p>


问:
From Imperative to Functional Programming
As an Electronic Engineer, my programming experience started with Assembly and continue with PL/M, C, C++, Delphi, Java, C# among others (imperative programming is in my blood).

I'm interested in add to my previous knowledge, skills about functional programming, but all I've seen until now seems very obfuscated and esoteric.

Can you please answer me these questions?

1) What is the mainstream functional programming language today (I don't want to get lost myself studying a plethora of FP languages, just because language X has the feature Y)?

2) What was the first FP language (the Fortran of functional programming if you want)?

3) Finally, when talking about pure vs. non pure FP what are the mainstream languages of each category?

Thank you in advance

答:
Tongue slightly in cheek, I'd answer: Lisp, Lisp, and Lisp.

For question number one, this is probably a controversial answer. People who are comfortable with the Microsoft development stack would, of course, consider F# to be more mainstream - after all, it's right there in your developer's tool chain, ready to be installed (or already there) on millions upon millions of PCs. The academic community is more excited about Haskell, but here also real-world usage is less than they would like to achieve. Telecom engineers swear by Erlang instead. But when taking all dialects together - Scheme for teaching and extension languages, Common Lisp for enterprise-size applications, Emacs lisp for the one true editor, Clojure for the cool young Java kids... they might just be the most-used predominantly functional language out there. (Note that programming language market share is an intensely politicized topic, and any answer you receive will be ripped to shreds by other opinions.)

Question two is easy. Unless you want to count the purely mathematical lambda calculus, Lisp was first - although it, too, was initially intended just as a mathematical modelling tool, it turned out to be easily implementable, and the rest is history. That was in the 1950s.

Question three: Common Lisp is decidedly non-pure, while Scheme more closely resembles pure axiomatic systems like Haskell, which rigorously separate side effects from computation. Again, questions about market share are always controversial, and Scheme is certainly not the purest FP language, just (I guess) the most used - even if much of this is due to cohorts of computer science freshmen. And Common Lisp is not the least-pure language either - I think all of the the various "Lisp on the JVM" tools are less pure, since leveraging the huge Java library ecosystem is one of their reasons for existence. If I were forced to guess, I'd say one of them will probably the next big winner in functional programming.


问:
Good practices every startup should follow
A couple of friends at work an me are going to set up a little startup / create our own software, probably moonlighting at first, since we cant yet afford to quit our day jobs.

Neither of us has have this experience, we've all worked for other companies before, where a set of guidelines are set, and I think this is the time to establish good practices to follow (like avoiding meeting-itis).

For people that have gone this way, what piece(s) of advice would you give us?

I'm looking more for the technical side of things, things such as:

Is it worth to have some kind of
build server or is that going to far
ahead?

Would you do extensive TDD or do you
think it would be too much overhead
for a small team that is not too
experienced with it?

But wouldn't mind to listen to the management side of things.

The project is a web application done in ASP.NET MVC, I'm thinking of using Mercurial and BitBucket or Kiln + FogBugz or some other online project tracking tool, since we are going to be working remotely.

答:
if the team is more than just you, standards matter. They don't have to be complicated ("use meaningful variable names, CamelCase, and don't break the build"). TDD rocks because it works, use it. The tests you come up with also make a great foundation for demos at the drop of a hat. A build server may be overboard, it may not; start without one and see how it goes. Tracking tools likewise; can add later as needed.

Assuming this product is to be sold, do some market research now, to make sure you're building something that people actually want. Outline a business plan to go from zero to market, divide responsibilities and equity, and hold each other accountable.

Good luck!


答:
1) What is the mainstream functional programming language today (I don't want to get lost myself studying a plethora of FP languages, just because language X has the feature Y)?

I'd be very hesitant to name a single one here. FP itself isn't really mainstream at all, so calling any FP language "mainstream" would be silly.

There are a few FP programming languages that seek contact with mainstream programming, e.g. Scala, F#, and Clojure, by piggy-backing on a mainstream platform (e.g. JVM or .NET), and there are a few mainstream programming languages with at least some degree of FP support (JavaScript being the most popular).

Within the realm of FP, Lisp (Common Lisp and Scheme being the most prominent dialects, with Clojure as a relative newcomer) is probably leading the pack in terms of number-of-users, as well as library and platform support. Unless of course you count JavaScript, which is surprisingly similar to Scheme in many ways (if you can look past the syntax).

2) What was the first FP language (the Fortran of functional programming if you want)?

Definitely Lisp. No doubt about that.

3) Finally, when talking about pure vs. non pure FP what are the mainstream languages of each category?

If you want really pure, there is actually very little choice - Haskell makes a point of being completely pure (the language itself: the runtime can and usually does execute impure actions), and there are a few experimental languages that follow a similar philosophy but differ from Haskell in various ways. AFAIK, the other ones all allow impure constructs in one way or another, some being more academic about it than others.

Title: From Imperative to Functional Programming

Body:
As an Electronic Engineer, my programming experience started with Assembly and continue with PL/M, C, C++, Delphi, Java, C# among others (imperative programming is in my blood).

I'm interested in add to my previous knowledge, skills about functional programming, but all I've seen until now seems very obfuscated and esoteric.

Can you please answer me these questions?

1) What is the mainstream functional programming language today (I don't want to get lost myself studying a plethora of FP languages, just because language X has the feature Y)?

2) What was the first FP language (the Fortran of functional programming if you want)?

3) Finally, when talking about pure vs. non pure FP what are the mainstream languages of each category?

Thank you in advance


问:
What does "general purpose system" mean for Java SE Embedded?
The Oracle website says this about Java SE Embedded license:

development is free, but royalties are required upon deployment on
  anything other than general purpose systems

What does "general purpose system" mean here?

We have a sensor network around the country. On each box we have installed, there is a micro controller based board that gets data from the environment and send data on serial port to a ARM based embedded board. On this board system there is a Java process which reads and submits data to our central server using JMS. Is this categorized as general purpose system?

Sorry I'm asking this here. We are in Iran, there is no Oracle office here to ask.

答:
"General purpose" is defined in the license itself. The Java 7 SE license has this:

"General Purpose Desktop Computers and Servers" means computers, including desktop and laptop computers, or servers, used for general computing functions under end user control (such as but not specifically limited to email, general purpose Internet browsing, and office suite productivity tools).

The use of Software in systems and solutions that provide dedicated functionality (other than as mentioned above) or designed for use in embedded or function-specific software applications, for example but not limited to: Software embedded in or bundled with industrial control systems, wireless mobile telephones, wireless handheld devices, kiosks, TV/STB, Blu-ray Disc devices, telematics and network control switching equipment, printers and storage management systems, and other related systems are excluded from this definition and not licensed under this Agreement.

(emphasis added)

You should also read the Embedded FAQ items 10 through 14, especially:

Q10. How is Java SE Embedded licensed?

Java SE is free to use for development of embedded applications. We provide affordable licensing for deploying Java SE in an embedded device or as part of a embedded-based system. Please contact us when you are ready to deploy or if you have already deployed but not sure you have the correct license.

Q11: Does deploying Java SE embedded devices or purposes require a royalty?

Yes. Oracle's license for Java SE enables it to be freely used for general purpose desktops or servers. If Java SE is bundled as part of a dedicated solution that involves or controls hardware of some kind, then it's likely an embedded application and is subject to modest royalty payments.

I'm not a lawyer, not familiar in any way with laws in Iran and how licensing works there, nor do I work for Oracle – but what you describe doesn't fit with the usual definition of "general purpose" system.

One more note: export restrictions may apply.

ALL Oracle products are prohibited for export/reexport to the following:

Any company or national of Cuba, Iran, North Korea, Sudan, and Syria. Licenses to these countries and parties are presumed denied.
[...]


问:
Should I Use WCF For My Purpose?
I wrote two programs that server and client can connect to each other (one program for server and another for client) with their IP addresses (socket programming).

Now I want to modify it so that if the client or server for example wrote something in textbox other user be notify of that.

My programs are Windows Form Application.

For this purpose, should I use WCF?

答:
Using WCF has both advantages and disadvantages compared to direct socket programming.

The main advantage is that you do not need to care about programming a server loop or communication protocol. You split your communication into function/method calls, include these functions/methods in your contract interface, create a class that implements it, instantiate and open a ServiceHost of that class' type, and your server is ready. For a nice condensed example see http://www.codeproject.com/Articles/14493/WCF-Basic-Client-Server.

There are a few downsides. For one, WCF is not really a small topic, and chances are that you'll still be reading at the time your socket programming would be done. You need to learn how endpoints, addresses, bindings are configured and what combinations make sense.
Furthermore, WCF is a big thing with a lot of abilities and options, and may create overhead when used for very trivial tasks.

I think you indeed should give WCF a try. Your WCF tasks so far are simple. You can modify the example on codeproject to get there quickly; people writing are slow, so overhead is no issue; you will get an understanding of WCF which may help your future.

On the other hand, you already have a socket open, and could just use that for communication. You'd have to read from the socket in a loop, write similar code twice (once for packing, once for unpacking from the stream), always assure that both codes get the same changes, ...

Title: Should I Use WCF For My Purpose?


问:
schedule compliance and keeping technical supports and resolving issues
I am an entrepreneur of a small software developer company. The flagship product is developed by myself and my company grew up to 14 people. One of pride is that we've never have to be invested or loaned.

The core development team is 5 people. 3 are seniors and 2 are juniors.

After the first release, we've received many issues from our customers. Most of them are bug issues, customization needs, usage questions and upgrade requests.

The issues from customers are incoming many times everyday, so it takes little time or much time of our developers. Because of our product is a software development kit(SDK) so most of questions can be answered only from our developers. And, for resolving bug issues, developers must be involved. Estimating time to resolve bug is hard. I fully understand it. However, our developers insist they cannot set the any due date of each project because they are busy doing technical supports and bug fixes by issues from customers everyday. Of course, they never do overwork.

I suggested them an idea to divide the team into two parts: one for focusing on development by milestones, other for doing technical supports and bug fixes without setting due days. Then we could announce release plan officially. After the finish of release, two parts exchange the role for next milestone.

However, they say they "NO, because it is impossible to share knowledge and design document fully." They still say they cannot set the release date and they request me to alter the due date flexibly. They does not fix the due date of each milestone. Fortunately, our company is not loaned and invested so we are not chocked. But I think it is bad idea to keep this situation. I know the story of ant and grasshopper.

Our customers are tired of waiting forever of our release date. Companies consume limited time and money. If flexible due date without limit could be acceptable, could they accept flexible salary day?

What is the root cause of our problem? All that I want is to fix and achieve precisely due date of each milestone without losing frequent technical supports.

I think there must be solution for this situation. Please answer me.

Thanks in advance.

PS. Our tools and ways of project management are Trello, Mantis-like issue tracker, shared calendar software and scrum(collected cards into series of 'small and high completeness' projects).

答:
This is a common and challenging problem. Many customer issues are genuinely lengthy research projects in their own right, and until they are fully understood, it is just not possible to estimate the effort required to fix them.

One solution to this is to dedicate two developers at a time strictly to issue resolution, rotating the assignment to another pair of developers every three or four weeks.


答:
I see a few issues here:

Your software seems excessively buggy if your developers are being swamped with bug reports. You need to take a look (Root Cause Analysis) at the bugs being raised and see why they're occuring. If you don't do this you'll merely run into the same issues at each release.

Measure the bug fixing process. Record the date the bug was raised, the date the investigation began, the date a suggested fix was found. See if there are blockers here.

Is your documentation bad? Are your UIs unintuitive?

You don't seem to have the resources to support more than one version of your product. There comes a point when you stop maintaining old releases of products unless there are exceptional circumstances (critical/showstopper bugs), and if a customer wants something in an old product you have to know when to tell them No/It's not worth fixing.

You're the boss, if you want your employees to work in a new way they should. Listen to their protests but explain to them why things need to change and ask them if they can see alternatives.

Title: schedule compliance and keeping technical supports and resolving issues

Body:
I am an entrepreneur of a small software developer company. The flagship product is developed by myself and my company grew up to 14 people. One of pride is that we've never have to be invested or loaned.

The core development team is 5 people. 3 are seniors and 2 are juniors.

After the first release, we've received many issues from our customers. Most of them are bug issues, customization needs, usage questions and upgrade requests.

The issues from customers are incoming many times everyday, so it takes little time or much time of our developers. Because of our product is a software development kit(SDK) so most of questions can be answered only from our developers. And, for resolving bug issues, developers must be involved. Estimating time to resolve bug is hard. I fully understand it. However, our developers insist they cannot set the any due date of each project because they are busy doing technical supports and bug fixes by issues from customers everyday. Of course, they never do overwork.

I suggested them an idea to divide the team into two parts: one for focusing on development by milestones, other for doing technical supports and bug fixes without setting due days. Then we could announce release plan officially. After the finish of release, two parts exchange the role for next milestone.

However, they say they "NO, because it is impossible to share knowledge and design document fully." They still say they cannot set the release date and they request me to alter the due date flexibly. They does not fix the due date of each milestone. Fortunately, our company is not loaned and invested so we are not chocked. But I think it is bad idea to keep this situation. I know the story of ant and grasshopper.

Our customers are tired of waiting forever of our release date. Companies consume limited time and money. If flexible due date without limit could be acceptable, could they accept flexible salary day?

What is the root cause of our problem? All that I want is to fix and achieve precisely due date of each milestone without losing frequent technical supports.

I think there must be solution for this situation. Please answer me.

Thanks in advance.

PS. Our tools and ways of project management are Trello, Mantis-like issue tracker, shared calendar software and scrum(collected cards into series of 'small and high completeness' projects).


答:
You are right, you don't need to store the id in the object, as long as you only need to know it in your repository context.

The situation changes when you pass the object to code outside that context, code that did not request the object by id (and therefore doesn't know it yet), but needs the id for whatever purpose (eg. to place it on a list of ids that will be requested from the repository later, by yet another code).

In that situation, you have two options:

introduce a new function argument 'id' in the whole chain of functions between the repository context and the function where the id is needed

include the id in the object

In most of these cases, storing the id inside the object will be the better solution. It will also reduce code changes when the id is needed in unforeseen places, plus it might be helpful with debugging at times.

That's why I do it when I do it.

Title: Should an object know its own ID?


问:
Looking for a dynamic programming solution
Given a sequence of integers in range 1 to n. Each number can appear at most once. Let there be a symbol X in the sequence which means remove the minimum element from the list. There can be an arbitrarily number of X in the sequence.
Example: 1,3,4,X,5,2,X
The output is 1,2.

We need to find the best way to perform this operation.

The solution I have been thinking is:

Scan the sequence from left to right and count number of X which takes O(n) time.
Perform partial sorting and find the k smallest elements (k = number of X) which takes O(n+klogk) time using median of medians.

Is there a better way to solve this problem using dynamic programming or any other way ?

答:
Dynamic programming is unlikely to be helpful here. You've already got a O(n log n) solution, Dynamic programming tends to run more like O(n^2) or O(n^3). (There are exceptions, but I wouldn't expect to find a better solution here.)

What you can look at using is a size-limited heap. Basically, use the heap to hold the k smallest values found so far. For each new value, compare with the highest value in the heap, and replace it if we've got a lower one.

Truth be told, you'll probably need some big data sets for it to be worthwhile doing anything but invoking your language's builtin sort and taking a slice.


答:
when you set the value of a property, throwing an exception on an invalid value is fine

getting the value of a property should (almost) never throw an exception

for role-based access, use different/dumber interfaces or facades; don't let people see things they can't have!


答:
This is not something that my team does today but it's a proposed change to our process that I've been floating by other people for a little while (and I'm curious what the community thinks about this, so all comments welcome)...

You said your team is already doing scrum and have a backlog of work represented by cards. To a developer working on a new feature (new development) and getting it to work, is very similar to working on an existing broken feature (bug fixing) and getting it to work.  Work is work.

You, as a product owner, could treat bug fixing same way you treat new development tasks and prioritize them in the same backlog. Some bugs (or feature requests) can wait, others must be fixed. Some are very important, some can be fixed later. You can decide on these factors and put them in the appropriate place in the backlog and you can decide if they should be in current release or delayed till next one.

This way, as long as your team maintains point velocity, you should be able to get a rough idea of when the release is going to be completed.  All you have to do is plot a graph with two lines that interpolate the following data sets:

Your team's story completion - how many cumulative points are completed each iteration

Your teams's scope creep - total number of points which are part of the release. this number will obviously go up when you add bugs to be part of the release, but that's just a reflection of reality.

At a point in time where the two lines intersect is your estimated release date.

I agree with your developers that splitting the team is not ideal. Personally, I would hate to be isolated in maintenance land while the other part of my team drove the architecture and major design decisions without me. At the same time, if you feel that 2/5 developers should be dedicated to bug fixing, what about simply requiring that 40% of time (no more, no less) in a given iteration be dedicated exclusively to bugs, but the whole team would be involved?

Aside from figuring out the scheduling problem, as other mentioned, you as a team should also figure out the root cause of so many bugs coming in that they are affecting the schedule. Don't look for a solution yourself, instead hold a series of retrospective meetings and let the team drive the discussion. Work together to set reasonable quality goals/targets and then ask them for ideas on how to achieve them.

Don't know if your team is doing any of these today, but here some ideas:

Design reviews - before jumping into work, have a quick peer review of the work ahead. This gives a chance for a second set of eyes to spot potential problems before they get into code, which is much more expensive to fix.

Code review - With a help of code review tools (some are open source), code review process can be run very effectively. It'll help you share knowledge and identify potential problem areas before they even get into production code.

QA - do you have a dedicated testing team or do developers do their own testing? I find that developers tend to get conditioned or "get used" to how software works and they start overlooking usability issues. Fresh set of eyes from end-user perspective can find all kinds of things.

TDD/Automated unit tests - this one isn't easy and many teams have tried and failed at it. But if done right, it'll let you deliver components which would be much more solid and would not require your guys to come back to them month after month. Also for some engineers, who are not as detailed oriented, TDD can work wonders. I've worked with some guys who write decent code and produce functionality, but they consistently miss boundaries and what-if cases. I would argue that spending time up-front of writing test code would be a great investment vs. time spent after each one of those boundary cases is encountered by the customer and requires a fix after the release. With TDD, it's another opportunity to verify use case scenarios and then simply let developers loose. When tests pass, you'll be much more comfortable that you are releasing something with quality.


问:
What are the benefits of using the command line for software development?
What benefits are gained from using the command line for software development over using an alternative GUI? Is the command line faster for certain tasks? Are certain tools only available via the command line?</p>

答:
Advantages of the command line over GUI applications include:

If you are writing such tools rather than using them, the command line is easy to develop for. Accepting arguments on the command line is trivial and outputing to a text stream is similarly easy.

Command line applications can easily be used in batch files or scripts, which is great for automated testing or builds. Most build tools, like make, ant and msbuild provide good support for calling command line tools.

The input, output and error streams can easily be redirected, allowing information to be sent or received from files or other applications. This can mean test data can be easily supplied or output captured.

There is a simple but standard error return mechanism (return code and the error stream). Detecting an error in a GUI may require UI automation.

Use over remote shell or similar connections makes it much easier to perform tasks remotely, such as when a developer is connecting from home or on the road. Remote desktop connections are more prevalent these days but require more bandwidth and a lower latency connection.

There are defined standards for help (such as the unix man command or passing -? as an argument). If someone does not know a feature, they can easily see what the tool provides. Similarly, there are defined wildcard syntax standards for specifying multiple files, drawing on likely existing developer knowledge.

However, command line applications have these disadvantages compared to GUI applications:

Command line applications are harder to learn to use, particularly for those not used to them. This is usually not a problem for software development because developers are often used to command line tools but could be problematic for less technical people involved in development such as junior QA, localization and technical writers.

Command line applications require a keyboard and so are impractical for some devices like phones or tablets.


答:
Your CTO is 100% Wrong.

Your Financial numbers MUST add up at all times. That means you need ACID and relational DB are the best place to insure that. The Performance gains of NoSql DB are usually at the Expense of ACID and that is OK for Google and Facebook BUT NOT for a system containing financials.

To say that C# performs better than SQL code is also idiocy…

Title: Is having functionality in DB a road block to scalability?

Body:
I may not be able to give the right title to the question. But here it is,

We are developing financial portal for wealth management. We are expecting over 10000 clients to use the application. The portal calculates various performance analytics based on the the technical analysis of the stock market.

We developed lot of the functionality through Stored procedures, user defined functions, triggers etc. through Database. We thought we can gain huge performance boost doing stuff directly in database than through C# code. And we actually did get a huge performance boost.

When I tried to brag about the achievement to our CTO, he counter questioned my decision of having functionality implemented in database rather than code. According to him such applications suffer scalability problems. In his words "These days things are kept in memory/cache. Clustered data is hard to manage over time. Facebook, Google have nothing in database. It is the era of thin servers and thick clients. DB is used only to store plain data and functionality should be completely decoupled from the database."

Can you guys please give me some suggestions as to whether what he says is right. How to go about architect such an application?


答:
It does not look like DP would be of much use to solve your problem, because it does not exhibit the optimal substructure property.

The problem can be solved very efficiently with a priority queue: when you see a number, negate it, and add the result to the priority queue. When you see an X, dequeue the highest-priority number, and negate it again before adding it to the answer.

Title: Looking for a dynamic programming solution

Body:
Given a sequence of integers in range 1 to n. Each number can appear at most once. Let there be a symbol X in the sequence which means remove the minimum element from the list. There can be an arbitrarily number of X in the sequence.
Example: 1,3,4,X,5,2,X
The output is 1,2.

We need to find the best way to perform this operation.

The solution I have been thinking is:

Scan the sequence from left to right and count number of X which takes O(n) time.
Perform partial sorting and find the k smallest elements (k = number of X) which takes O(n+klogk) time using median of medians.

Is there a better way to solve this problem using dynamic programming or any other way ?


答:
1) There is none. Possible choices are F# (that comes from MS and integrates with Net framework), GHC Haskell (compiles to native code on several most popular platforms, bindings to many C and C++ libraries are available), scala (jvm choice, though it has limitations). For dynamic typing look onto Erlang (crossplatform, makes emphasis on concurrency, parallelism and network communications) and lisp descendants: clojure (for JVM platform), racket scheme (native code).

2)lambda calculus. It is only math model, though. The first implemented FP language was Lisp and later SASL.

3)For pure FPL it is currently haskell - the only widespread pure lazy FPL (though GHC dialect has impure features). For impure there is no clear leader. SML family is dying except F#, so I'd probably stick with F# (They say it has problems with Mono) or some Racket dialect.

In addition to Pure/Impure holywar beware of Static/Dynamic typing holywar. I clearly stay on Static side, but I'm well aware that many prefer Dynamics (lisp dialects, Erlang and so on).


答:
I assume you mean using a command-line compiler instead of an IDE. Leave a comment if not and I'll delete my answer.

Learning. Learning how units of code are compiled, linked, or mapped together in your language. Typically you must explicitly tell the compiler which files to compile and link. So you gain a better understanding how it works. An IDE will do magic to make your life easier but will keep you ignorant.

You then take it a step further and learn to create your own make-file. This is a valuable skill. Your make-file makes the build cycle approach the convenience of "IDE magic" while still retaining full understanding and learning.

In addition your build process is easy to put in source control. And it's easy to port your build process to work with a variety of compilers. Sometimes it's just a matter of changing 1 line in the make-file for the compiler name.

You develop skills that allow you to work many platforms. Text editors and command line compilers are very similar from all vendors and on all platforms. These basic tools give you a pass to develop on any system, any time, any where 24/7.  If you've been living in Visual Studio all your life, it's going to be a much harder transition to work outside of it.

If you go down this path you may want to bother to learn an advanced text editor like VIM. It complements the ability to work on any platform since it's supported almost everywhere. It has a huge learning curve but the pay off is the ability to edit text effortlessly at high speed without moving your hands to the mouse.

BTW, I am not against IDEs.

Title: What are the benefits of using the command line for software development?

Body: What benefits are gained from using the command line for software development over using an alternative GUI? Is the command line faster for certain tasks? Are certain tools only available via the command line?</p>


答:
If you have too many bugs in your current version, then dedicating resources to the next version (before reducing the bug count) is going to only add more bugs.

I'd make it a priority to

prioritize the existing bugs

find and fix the high priority ones

perform a Root Cause Analysis to figure out why you're getting so many bugs

Tell your developers to SLOW DOWN.  Writing buggy code quickly is more damaging than writing stable code slowly.


问:
What would you think of a job based on mostly doing the proof of concept?
I'm working as a developer in a small software company whose main job is interfacing between separate applications, like between a telephony system and an environment control system, between IP TVs and hospitality systems, etc...And it seems like I am the candidate for a new job title in the company, as the person who does the proof of concept of a new interfacing project and does some R&D for prototyping.

What do you think the pros and cons of such a job would be, considering mainly the individual progress/regress of a person as a software engineer? And what aspects would you consider essential in a person to put him/her in such a job position?

答:
sounds like fun! you get to work with the new shiny stuff, figure it out, prove that it can work, then go on to the next new shiny thing.

progress/regress is totally up to you. qualifications: no fear, inventiveness, ability to mentor


答:
My professional experience is limited to a few small companies with small development teams.  So take this comment for what it's worth from my own perspective.

Regardless of how you perceive the relevance of your resume, the fact is that it is still highly relevant in the workplace. HR recruiters aren't the only ones who will screen your resume. In our teams, our Lead and Senior developers (usually 1 or 2), in addition to our managers are offered the chance to screen your resume and offer an opinion on whether or not they feel they want to talk to you.

That's the key point.  We're not evaluating your expertise at this point.  We're trying to figure out if you've done similar things to what we're doing.  We're trying to figure out how you communicate those achievements and whether or not you thought they were important to you.

Reviewing your code on GitHub, your reputation and answers on StackOverflow, and other online resources is the equivalent of a research project to me. While this definitely answers questions I might have about your techincal abilities, I just don't have the time to go reading other people's code. I've already got deadlines to meet.

I could spend 5-10 minutes looking over your resume and highlighting the things that are interesting to me.  Or I could spend up to an hour trying to summarize myself what I think your qualifications are. And if I have to summarize you, that means that I likely won't accurately represent you to my superiors or my team.  It'll be your word against mine about who you are and what you're capable of.

You wouldn't want me judging your work by a single item in your online portfolio, right?  That wouldn't be fair to you.  But that's usually the amount of time I have in my professional day to make a decision on whether or not we just want to talk to you.  So be fair and considerate of my time by summarizing what you think are your best selling points.  If I have to go hunt them down myself, you've already raised red flags in my point of view.

Not submitting a resume immediately tells me you don't care enough about the hiring process to put in a minimal amount of work.  Why would I consider hiring you if the projects I have in store for my new hire are a considerable load of additional work?

Title: What is the relevance of resumes in the age of GitHub, Stack Exchange, Coursera, Udacity, blogs, etc.?

Body:
My resume is no longer relevant. It can no longer contain an adequate description of my technical abilities. One can get a much better sense of what I am capable of by looking at my GitHub repositories, my Stack Exchange profiles, and the various courses that I am taking at Udacity and Coursera. The problem is that I have no idea how to tell employers that those are the places to look if they want an accurate description of what I can do.

Every time a recruiter contacts me I gently nudge them towards all the resources I just mentioned and I also provide a link to a publicly visible Google doc that contains my resume along with links to all those resources. Yet, they keep coming back asking for a more descriptive resume.

How can I make it even more blatantly obvious that if somebody wants to hire me then they can save themselves a whole bunch of trouble by just clicking on a few links and browsing around?


问:
How are crossplatform/multiple-OS C++ projects planned in terms of code and tools?
I want to create a project in C++ that can work in Windows, Linux and Embedded Linux.

How are projects created when they have to work across many OS'es? Is it first created on one OS and then the code slowly modified to be ported to another OS? Eg: to me, the Linux version of Firefox appears to be created as a Windows project and a separate Linux project with a different code base, since Firefox behaves a bit different in Windows and Linux. Although the source code download is surprisingly a single link.

If QT is used for UI, Boost threads for threading, Build Bot for CI and NetBeans/Eclipse/QT Creator for an IDE, would a person be able to minimise the amount of code re-write required to get the project onto another OS? Is this the right way to do it, or are such projects meant to be created as two entirely separate projects for two separate OS'es?

答:
The key is to isolate non-portable parts of the code from the main code base.

For example, the directory structure could include a directory called shared/ which would then include all the portable and shared code and content. Then whatever non-portable code would be located in specific directories which group the behaviour. For example GUI/.

When it comes to actual code, you can do multiple implementations and use conditional compiling either via separate source files for separate platforms(e.g. GUI/Qt/Linux/<linux_specific_files>) and then use some build system to define what kind of build you want to create(say a generic Linux build with Qt or GTK, granted that you have both implementations). Another way would be to use preprocessor directives to include/exclude parts of the code upon compilation. Simple example would be as follows:

```<code>#ifdef XX_LINUX_BUILD
    // Linux specific code here
#endif
#ifdef XX_WINDOWS_BUILD
    // Windows specific code here
#endif
</code>```

...where XX denotes some unique identifier for the project to avoid collisions. Then, upon compiling, you'd just define either XX_LINUX_BUILD or XX_WINDOWS_BUILD via your build script which sets the required compiler command line arguments(e.g. -DXX_LINUX_BUILD with GCC/g++).

Body:
The key is to isolate non-portable parts of the code from the main code base.

For example, the directory structure could include a directory called shared/ which would then include all the portable and shared code and content. Then whatever non-portable code would be located in specific directories which group the behaviour. For example GUI/.

When it comes to actual code, you can do multiple implementations and use conditional compiling either via separate source files for separate platforms(e.g. GUI/Qt/Linux/<linux_specific_files>) and then use some build system to define what kind of build you want to create(say a generic Linux build with Qt or GTK, granted that you have both implementations). Another way would be to use preprocessor directives to include/exclude parts of the code upon compilation. Simple example would be as follows:

#ifdef XX_LINUX_BUILD
    // Linux specific code here
#endif
#ifdef XX_WINDOWS_BUILD
    // Windows specific code here
#endif

...where XX denotes some unique identifier for the project to avoid collisions. Then, upon compiling, you'd just define either XX_LINUX_BUILD or XX_WINDOWS_BUILD via your build script which sets the required compiler command line arguments(e.g. -DXX_LINUX_BUILD with GCC/g++).


问:
Sites with overlapping code-bases. Developing multiple sites with little changes
I have to develop 3 different sites

video.com for hosting video

audio.com for hosting audio

docs.com for hosting docs.

domain names for example only

Almost 80% of the functionality is the same for all the three, with remaining 20% being completely different features...

How do I handle this? How does sites like SO handle this?

I am developing this in YII framework and was thinking of having these different features as modules but in this case the menu/code links in html code can become difficult.

答:
The way we've done it at companies I've worked at is that we have a common code line in source control. This is where that 80% of code lives. It is 100% functional and could be deployed on it's own if needed. It's like the vanilla website.

When a new website comes along that needs to build on this base, we branch the code from the common line into a new project. All customization are done in that branch with releases coming from there.

If a bug in the common code is discovered in a project, then it is fixed in the common line and then pushed to all the projects so that all projects get the fix. You never push from a project site down into common code, you always push from common code out to project sites.

As for skinning a site. Using CSS helps a lot. I follow Jeff Atwood's blog, Coding Horror, and he did a post that really helped us out. It was how I was introduced to less. It goes into how the Stack Exchange network is able to skin their sites quickly and easily.

You can find the post here. I'm not sure if there is a way to use it in php, but it's something to look into. It has been a life saver for us at my current company.


问:
Android Development: MVC vs MVVM

Possible Duplicate:

  Is Model-View-Presenter (MVP) scheme useful for Android?

I've started coding for Android and I'm having difficulty trying to properly partition my code. I always end up with a very tight coupling between my UI logic and the actual controls I use to represent them.

I have background in both WPF MVVM and ASP.NET MVC so I'm familiar with those patterns. After some digging, I found Android Binding. It seems nice and fits nicely with my WPF background. However, it bugs me that its not built in. I'm pretty sure that the Android makers have thought of this when designing the Android programming interface. So my question is, what is the best practice pattern to use when developing in Android, if any. I have looked and looked at their site but didn't find anything...

答:
When I start work on Android I know about MVC. Now I try to make Android app using MVC but when I start I success but here I write many lines of code without any purpose. And at the end my app having many line of codes which are only write for making MVC. Not for functionality. But now I am using my own design which is very good for me I make many big apps with this approach.

I give you small example or if you need more help I send you some template of code.

First decide what are the main functionality of your app like Your app having tabs or having only lists.

Instead I made scenario of an app at run time. Now suppose we have an app which save some data on local DB and it also get data from Server in JSON. After that I have list to show JSON data. And there are some sounds also play in the app in background. Now I also want to show data from mobile contacts. And also want to add social integration like FB etc.

Now start of code.

First create packages:

1.com.app.startup/splash   (Splash + Initialization of any view here)

2.com.app.general  (Made Application Object + Constant file where save constants)

3.com.app.functionalities (Any functionality like Map,Social media etc)

4.com.app.webservices (Mostly Async task which load data from Server)

5.com.app.jsonparsers (Used in webservices to parse json and save in model)

6.com.app.models (Create your models)

7.com.app.adapters (Because many list so make list here)

8.com.app.main (Here mostly main activities code like dashboard, ListsActivities)

9.com.app.interfaces (Create interfaces which create easiness in working with     ListActivities and adapters)

I think now you can handle any project in Android in this manner.

Title: Android Development: MVC vs MVVM


问:
AGPL License - does it apply in this scenario?
There is an AGPLv3 based software (Client) that makes web service calls (using SOAP) to another software (Server - commercial, cloud based). There is no common code or any connection whatsoever between these two except for the web service calls being made.

My questions -

Does the Server need to be AGPL too?  I guess not - but would like to confirm.

Let us say the end point URL for the Server can be configured on the Client side (by editing an XML file) to connect it to different Servers (again, there is no connection other than the webservice calls being made) does it require any of these Servers being AGPL?

Are there any issues in running the Client as a DLL that is loaded by other commercial applications on users' desktops? Does it require these other applications also to be AGPL?

答:
As far as any version of the GPL goes, there is no distinction between
  commercial and non-commercial distribution of the code. If you
  distribute, you need to do so under the same license, and with copies
  of the source code.

Since this is the Affero version, if you use aloha on the server side
  of your website, it still counts as distribution, and you need to
  provide the source code. You may not make your own changes to the
  source code and keep them private. If you're just using it, this
  should be easy; you can probably get away with pointing people to
  where you got aloha.

There is no requirement whatsoever to distribute any data. This is
  source code only.

Reference


答:
Release as fast as possible. Chances are 90% of the code you start with will not make it past the first 6 months. So there's no point in engineering it like crazy. Code as quickly as possible to get to market, then let your users decide how to develop it further. If TDD is how you code quickest, use TDD. Otherwise, just hack it. Early-adopter users are pretty forgiving of a few bugs when your product is in beta.

Don't waste your time being sys admins. You've got the right idea with hosted platforms for bug-tracking (e.g. FogBugz) and source control. Use an online document repository such as Google Docs. If you do store anything locally, use an online cloud backup service such as Carbonite. On your live environment, rent a fully managed hosting solution if you can afford it. Try to tend away from having to maintain your own servers.

Concentrate on what makes you unique. If you find yourself writing code that seems like it must've been done before, use what's already there. Become experts at solving your business problem and don't get distracted by problems outside your domain.

Title: Good practices every startup should follow

Body:
A couple of friends at work an me are going to set up a little startup / create our own software, probably moonlighting at first, since we cant yet afford to quit our day jobs.

Neither of us has have this experience, we've all worked for other companies before, where a set of guidelines are set, and I think this is the time to establish good practices to follow (like avoiding meeting-itis).

For people that have gone this way, what piece(s) of advice would you give us?

I'm looking more for the technical side of things, things such as:

Is it worth to have some kind of
build server or is that going to far
ahead?

Would you do extensive TDD or do you
think it would be too much overhead
for a small team that is not too
experienced with it?

But wouldn't mind to listen to the management side of things.

The project is a web application done in ASP.NET MVC, I'm thinking of using Mercurial and BitBucket or Kiln + FogBugz or some other online project tracking tool, since we are going to be working remotely.


问:
Finishing an iteration early
I'd like some input on this on those working with agile methodologies...

A current project is finding that development on our planned user stories is finishing some time before the end of the iteration, and that the testing effort and business acceptance is what's actually dragging us out longer towards the end. This means that the devs in question have spare time, and they're essentially going out to the iteration+1 backlog and starting work on cards there before our current iteration cards are 'done'. As iteration manager, I want to put a stop to this - I want a more team-orientated approach where the group takes ownership of getting all the cards done, as opposed to "Well, dev's done so what do I dev next?"

The problem I face is convincing the team of this. On one hand, I understand why the devs don't want to test the code they've written (there are unit tests they write of course, but the manual testing to be done could be influenced by their bias). The team sees working ahead as making our next iterations easier, because a lot of the work is done before we start. I see this as screwing with the whole system of planning/actuals - but it's difficult to convince the team as to why this matters.

What advice can you guys and girls give? How do we stop devs reaching ahead? What should they be doing instead? How much of a problem is this in the scheme of things, if things are still getting done?

答:
As long as you keep pushing for more stories during the sprint it will be hard to avoid this behavior.
Instead let people spend the rest of the sprint with whatever they are up to, except new stories. I guess there is a myriad of things that can be done: from build automation, learning that cool new tool from last week, testing or having that barbecue that you could have had for weeks.
A new sprint can be planned accordingly in order to do more stories in a new iteration (if that is the goal).

If you can speed up test and acceptance, then do so. If you can't, this is a limiting factor.

Title: Finishing an iteration early


答:
Drupal makes quick work on running multiple sites from a single codebase - http://drupal.org/node/43816

I do believe CodeIgniter also has a very good ability to build a cluster of sites using the same codebase - http://philsturgeon.co.uk/blog/2009/06/How-to-Multi-site-CodeIgniter-Set-up

Title: Sites with overlapping code-bases. Developing multiple sites with little changes

Body:
I have to develop 3 different sites

video.com for hosting video

audio.com for hosting audio

docs.com for hosting docs.

domain names for example only

Almost 80% of the functionality is the same for all the three, with remaining 20% being completely different features...

How do I handle this? How does sites like SO handle this?

I am developing this in YII framework and was thinking of having these different features as modules but in this case the menu/code links in html code can become difficult.


答:
Extract as much business functionality as possible into separate common modules (in case of our asp.net applications we use separate projects within a solution for generic logic in an application and a separate common solution for core/helper modules used across a range of a applications),

Do not hardcode, make things configurable either through some kind of config files or store configuration in a db. Use a separate config/db for each domain. This allows you to keep a single codebase and decide on deploy which 'flavour' of the application to use. This applies just as well to site-specific constants, db connection strings (those you obviously can't store in a db), css files to use and site content, including site navigation,

Break down pages into components. Use user controls or whatever the equivalent in PHP may be (turns out it's not as simple as I thought, but you might want to check this SO question). You can assemble the components as needed and reuse them between sites,

Use separate css files if there are vast differences in design of the sites, otherwise use the same css as a base and introduce site-specific styling using a top-level class (e.g. use .btn for base styling of buttons and .audio-com .btn or .video-com .btn for site specific styling). Using css preprocessors like LESS or SASS makes this approach feel natural. Tyanna provided a link to a blog post on the topic in an earlier answer,

Avoid forking the codebase. If you can't, at least make sure you have a decent working codebase before you do so. If you're writing from scratch, finish one site as a prototype, and only then fork. Having to maintain and apply bug fixes to three separate codebases is a hassle, and will only get worse as your codebases diverge with time. In general, this is a decision you shouldn't take lightly, even if it will make your life simpler for the moment. It will come back to you if/when you'll be tasked with maintaining the sites.


问:
How do programmers quit a job?
I'm thinking about leaving my current employer and wondering how one goes about that process in the programming world. We have a lot of projects on the go at the moment and I'm the only developer. We have 4-5 projects that are fairly big and need to be done in the next few months and even a few longer than that.

I'm leaving because I'm the only employee and that's doing me no good. I'm young and want to learn, so a team would be nice. It's also too much work and the company is managed horribly.

I have no contract to worry about so I could theoretically quit and just not come back without notice. Just wondering how this is normally handled.

Should I write a resignation letter

How much notice should I give

Should I give a reason for leaving

Should I go to my boss who is the main reason I'm leaving or go to his boss?

Overview of replies

From the feedback here, it looks as though it's best to give 2-4 weeks of notice, and present a written resignation. Don't go into detail explaining why you're leaving in most cases. Don't burn bridges. Be professional.

答:
Based on past experience, resignation letters should be 3 and only 3 sentences.

I will be resigning my position at $company.

My last date of work will be $date.

My address is $address.

3.14 Sign and date the letter.

Before you hand this letter in, have all your personal belongings out of the company, as many companies will escort you to the door and disable your access (physical and computer) immediately. Not all do, but I came close to losing several shelves of books at one place notorious for letting you know you're laid off by disabling your keycard so you can't get in to recover your stuff (it was regulated as a bank, but they took no deposits). You do not want to be at the mercy of someone who decides they want your books (or feel that they are the company's books), or red stapler or other possessions as you will no longer have any sort of recourse to recover them.

Reason for sentence 1: it is a resignation letter, there needs to be zero misunderstanding about what is going on. It needs to be in writing as I've worked for bosses who deny that the person quitting was quitting so as to screw with them starting elsewhere.

Reason for sentence 2: I've worked for places that have backdated resignation letters and claimed you quit today - not in 2 weeks. Consequently, you may be expecting a paycheck that you'll never recieve. This is also why you date it with "today's" date when you sign it.

Reason for sentence 3: Many people move, and if you need COBRA benefits, or 401k paperwork, there have been places I've worked at where they would deliberately and maliciously send your paperwork to an old address so that you cannot reply in the mandated 30 day period (because either it was still tied up in the post office's change of address system, or if that expired, returned to sender).

Never ever add stuff about why you are leaving. It is none of their business. If they ask, answer verbally, but never in any sort of writing.

Even more importantly, never write a scathing lump of bile and anger. I've worked for one boss who made it a point to make sure that companies calling for references got a copy of those bile soaked missives.

Update: I handed in my resignation at my current employer today and this was the extent of the resignation letter. No, I didn't have all my loot out of the office, because I didn't get notified by the recruiter before end of business yesterday. Several of the guys laughed at how short it was, but understood when I explained (in more details) several of the points why it was so short.

Title: How do programmers quit a job?


问:
Would a typical corporate firewall block a Java applet having the following behaviour
I'm thinking of developing a proxy-like program to forward ports on a remote PC to a local PC (for example SSH).
Assume that both local and remote PCs are running behind typical firewalls (i.e. consumer broadband router firewall, Windows firewall or corporate firewalls).

The program will be a Java program which the user will run on both the remote and local PC.
The remote client will periodically poll a central server to determine whether there are pending client connections. A session could be initiated as follows:

The local client contacts the central server and request the current connection details for a specific remote client.

The central server responds with the remote server's last received IP address and port.

The next time the remote server polls the central server, the
    client's IP address and port are returned. The remote server
    initiates a connection to the local client using the IP address and
    port returned by the central server and listens for a response on a
    random port. The remote server will pass the value of the port it's
    listening on to central server.

Goto 1, if client fails to connect to server.

All coomunication with the central server will be via HTTP/HTTPS on ports 80 & 443.

Would this work or will a typical firewall block the interactions.

答:
A typical corporate firewall will block outgoing requests on all but ports 80 and 443 (even those may need NTLM authentication or something similar) and ALL incoming requests.

So no, that won't work.


问:
What is the relevance of resumes in the age of GitHub, Stack Exchange, Coursera, Udacity, blogs, etc.?
My resume is no longer relevant. It can no longer contain an adequate description of my technical abilities. One can get a much better sense of what I am capable of by looking at my GitHub repositories, my Stack Exchange profiles, and the various courses that I am taking at Udacity and Coursera. The problem is that I have no idea how to tell employers that those are the places to look if they want an accurate description of what I can do.

Every time a recruiter contacts me I gently nudge them towards all the resources I just mentioned and I also provide a link to a publicly visible Google doc that contains my resume along with links to all those resources. Yet, they keep coming back asking for a more descriptive resume.

How can I make it even more blatantly obvious that if somebody wants to hire me then they can save themselves a whole bunch of trouble by just clicking on a few links and browsing around?

答:
You need to remember your audience, and broaden your understanding of what they need to make you successful.

If I were a recruiter, how would I present your github repository as validation of your skills in a corporate setting?  Submitting such duplicates the work of determining what skills you have across every candidate that might be interested in you.  Would you be interested in spending thirty minutes digging through repositories determining if you used a tool set, or reading on your resume that you used it?

Take some time, and learn the process.  Then you will see that the resume is practically the only thing that holds the process together.  It is the "unit of work" in a hiring process.  Who is even going to know your name without one?  Developing skill in navigating the hiring process is a diversion from skill developed in other areas, but it is probably one of the most profitable non-programming skills to have.


问:
Is Operator Overloading supported in C
When I read about the LCC (Windows) compiler, I found out it has the implementation for operator overloading.

However, after a bit of Googling, I've confirmed that operator overloading isn't supported in standard C, although someone's comment mentioned LCC is ANSI-compliant.

Is LCC really standard C or is it just like objective-c, a C variant with object-oriented features?

答:
It looks to me like the LCC authors don't claim ANSI C compliance, but as you suggest in your question, have made their compiler support extensions to the C language.

"This document then, proposes the development of several enhancements to the language,
mostly compatible with their C++ counterparts. The main aim is to make C programming
easier, more secure and more flexible than it is now."

http://www.cs.virginia.edu/~lcc-win32/proposal.pdf

Operator overloading is definitely not part of ANSI C.

Title: Is Operator Overloading supported in C