答:
I've found LINQ to be handy in literally any scenario where I'm working with collections of objects.  The main things you do with collections of objects are:

Search them for items matching some characteristic

Traverse them to calculate some aggregate value

Visit each item in the collection and calculate some value based on it (translation)

Rearranging its contents for some purpose (transformation)

Each of these scenarios has a number of LINQ methods that are designed to help with the task:

For searching, there's Where(), First(), Any(), All(), Last()

For aggregation, there's Aggregate(), Average() Sum(), Max(), Min()

For translation there's Select() and SelectMany()

For transformation there's OrderBy(), GroupBy(), Reverse()

And a few other odds and ends that I'm not sure how to categorize in the above for - for example the set operations Union() and Intersect().

In general, all of these functions do the work of hand-coded loops, but have the advantage of improving legibility because they help to replace several lines worth of code with a few LINQ operations that are named after what they do.  For example, consider

```<code>string[] input;

var output = new string[input.Length];
for(int i = 0; i < input.Length; i++)
{
    output[input.Length - i - 1] = input[i];
}
</code>```

versus:

```<code>var output = input.Reverse().ToArray();
</code>```

Another advantage is that it's easy to string them together to get more complex behavior.  Say that instead you wanted to get only the unique values in the array, and sort them.  Right now I'm feeling too lazy to hand-code a solution to it, but I'm sure whatever it is it would be much longer and harder to read than

```<code>var output = input.Distinct().OrderBy(x=>x).ToArray();
</code>```

And it definitely would take longer, which is why I don't feel like writing it.

Title: How do I tell the cases when it's worth to use LINQ?

Body:
Many things in LINQ can be accomplished without the library. But for some scenarios, LINQ is most appropriate.

Examples are:

SELECT - https://stackoverflow.com/questions/11883262/wrapping-list-items-inside-div-in-a-repeater

SelectMany, Contains - https://stackoverflow.com/questions/11778979/better-code-pattern-for-checking-existence-of-value

Enumerable.Range - https://stackoverflow.com/questions/11780128/scalable-c-sharp-code-for-creating-array-from-config-file

WHERE https://stackoverflow.com/questions/13171850/trim-string-if-a-string-ends-with-a-specific-word

What factors to take into account when deciding between LINQ and regular .Net language elements?

Body:
I've found LINQ to be handy in literally any scenario where I'm working with collections of objects.  The main things you do with collections of objects are:

Search them for items matching some characteristic

Traverse them to calculate some aggregate value

Visit each item in the collection and calculate some value based on it (translation)

Rearranging its contents for some purpose (transformation)

Each of these scenarios has a number of LINQ methods that are designed to help with the task:

For searching, there's Where(), First(), Any(), All(), Last()

For aggregation, there's Aggregate(), Average() Sum(), Max(), Min()

For translation there's Select() and SelectMany()

For transformation there's OrderBy(), GroupBy(), Reverse()

And a few other odds and ends that I'm not sure how to categorize in the above for - for example the set operations Union() and Intersect().

In general, all of these functions do the work of hand-coded loops, but have the advantage of improving legibility because they help to replace several lines worth of code with a few LINQ operations that are named after what they do.  For example, consider

string[] input;

var output = new string[input.Length];
for(int i = 0; i < input.Length; i++)
{
    output[input.Length - i - 1] = input[i];
}

versus:

var output = input.Reverse().ToArray();

Another advantage is that it's easy to string them together to get more complex behavior.  Say that instead you wanted to get only the unique values in the array, and sort them.  Right now I'm feeling too lazy to hand-code a solution to it, but I'm sure whatever it is it would be much longer and harder to read than

var output = input.Distinct().OrderBy(x=>x).ToArray();

And it definitely would take longer, which is why I don't feel like writing it.


问:
Using business objects in view models
When using reusable business objects, what is considered best practice when building view models?

We use an object we call Builder to build our view models. One builder for each logical unit of views (orders, users etc), where each unit can contain a number of different view models (orders contains summary, order lines etc).

A builder may pull data through one or more standard business objects in order to build a view model.

What is considered the better practice when it comes to using business objects/models in view models?

Approach 1

Allow the use of business objects in the view model?

```<code>//Business object in some library
public class Order
{
    public int OrderNum;
    public int NumOrderLines;
    //...
}

//Order builder in website
public class OrderBuilder
{
    public OrderSummary BuildSummaryForOrder(int OrderNum)
    {
        Some.Business.Logic.Order obOrder = Some.Business.Logic.GetOrder(OrderNum);
        //Any exception handling, additional logic, or whatever

        OrderSummary obModel = new OrderSummary();
        obModel.Order = obOrder;

        return obModel;
    }
}

//View model
public class OrderSummary
{
    public Some.Business.Logic.Order Order;
    //Other methods for additional logic based on the order
    //and other properties
}
</code>```

Approach 2

Take only the necessary data from the business objects

```<code>//Business object in some library
public class Order
{
    public int OrderNum;
    public int NumOrderLines;
    //...
}

//Order builder in website
public class OrderBuilder
{
    public OrderSummary BuildSummaryForOrder(int OrderNum)
    {
        Some.Business.Logic.Order obOrder = Some.Business.Logic.GetOrder(OrderNum);
        //Any exception handling, additional logic, or whatever

        OrderSummary obModel = new OrderSummary()
        {
            OrderNum = obOrder.OrderNum,
            NumOrderLnes = obOrder.NumOrderLines,
        }

        return obModel;
    }
}

//View model
public class OrderSummary
{
    public int OrderNum;
    public int NumOrderLines
    //Other methods for additional logic based on the order
    //and other properties
}
</code>```

I can see the benefits and drawbacks to both, but I wonder if there's an accepted approach? In approach 1, there's no duplication of code around the models, but it creates a dependency on the business logic. In approach 2, you take only the data needed for the view, but you duplicate code around models.

答:
Option 1 is preferable as it avoids code duplication. That's it.

If the domain model changes significantly , it's almost certain that the view will have to change anyway. With option 2, then you have to change the view model AND the builder as well as the view itself. That kind of thing is absolute poison for maintinability. YAGNI.

The point of having a separate view model is to keep state that is meaningful only for the view (e.g. what tab is currently selected) separate from the business model. But the business data itself should be reused rather than duplicated.

ContentLicense: CC BY-SA 3.0

Title: Using business objects in view models


问:
Does Silverlight have a future?
Recently I have read some articles/blogs/comments about the development and history of WPF and Silverlight. In some forums many developers and users criticize the performance of WPF applications (for example Visual Studio 2010). Actually the market share of Silverlight in comparison to Flash is not very high. At PDC 2010 Bob Muglia said something like "our Silverlight strategy and focus going forward has shifted...." and Microsoft wants to push HTML5 in the future.

Additionally, Microsoft has announced HTML5 being a core part of the Windows 8 and Windows Phone 8 ("Mango") platforms.

Recently I have started learning Silverlight and now I must ask myself, if I should continue investing time in learning these (in my opinions) very nice and powerful technologies!? Does they have a future? Does (Windows) desktop (client) applications have a future? Does so called "Rich Internet Applications" have a future? Or will HTML5 become the "absolute truth" in software development?

What is your opinion and what do you think?

答:
I think it's all just conjecture at this stage. With the plan for an App Store built into Windows 8, the likely app technology would be Silverlight (given how it can be sandboxed in OOB, etc.). SL is likely to be around for years to come.

The other thing to consider about HTML5 is that the shift mentioned may be away from current crummy non-standard IE programming, not away from SL.

Title: Does Silverlight have a future?

ContentLicense: CC BY-SA 2.5


答:
Principles and mantras are sometimes valuable for guiding design... but here's my practical answer:

Imagine your view models being serialized into JSON or XML. If you try and serialize your domain models you're going to end up with a hideous mess of text and most likely run into issues with circular references and other issues.

The purpose of a view model is not to group domain models together so that the view can consume them. Instead the view model should be a completely flat model of the view... the actual thing you're looking at on the screen. Your view logic should only be concerned with structuring the data that is present in the view model.

Ideally your view model should be composed almost entirely of pre-formatted strings. Think about it... you don't even want a DateTime or decimal in your view model because then you're stuck doing formatting logic in C#, Javascript, Objective-C, etc.

Title: Using business objects in view models

Body:
When using reusable business objects, what is considered best practice when building view models?

We use an object we call Builder to build our view models. One builder for each logical unit of views (orders, users etc), where each unit can contain a number of different view models (orders contains summary, order lines etc).

A builder may pull data through one or more standard business objects in order to build a view model.

What is considered the better practice when it comes to using business objects/models in view models?

Approach 1

Allow the use of business objects in the view model?

```<code>//Business object in some library
public class Order
{
    public int OrderNum;
    public int NumOrderLines;
    //...
}

//Order builder in website
public class OrderBuilder
{
    public OrderSummary BuildSummaryForOrder(int OrderNum)
    {
        Some.Business.Logic.Order obOrder = Some.Business.Logic.GetOrder(OrderNum);
        //Any exception handling, additional logic, or whatever

        OrderSummary obModel = new OrderSummary();
        obModel.Order = obOrder;

        return obModel;
    }
}

//View model
public class OrderSummary
{
    public Some.Business.Logic.Order Order;
    //Other methods for additional logic based on the order
    //and other properties
}
</code>```

Approach 2

Take only the necessary data from the business objects

```<code>//Business object in some library
public class Order
{
    public int OrderNum;
    public int NumOrderLines;
    //...
}

//Order builder in website
public class OrderBuilder
{
    public OrderSummary BuildSummaryForOrder(int OrderNum)
    {
        Some.Business.Logic.Order obOrder = Some.Business.Logic.GetOrder(OrderNum);
        //Any exception handling, additional logic, or whatever

        OrderSummary obModel = new OrderSummary()
        {
            OrderNum = obOrder.OrderNum,
            NumOrderLnes = obOrder.NumOrderLines,
        }

        return obModel;
    }
}

//View model
public class OrderSummary
{
    public int OrderNum;
    public int NumOrderLines
    //Other methods for additional logic based on the order
    //and other properties
}
</code>```

I can see the benefits and drawbacks to both, but I wonder if there's an accepted approach? In approach 1, there's no duplication of code around the models, but it creates a dependency on the business logic. In approach 2, you take only the data needed for the view, but you duplicate code around models.


问:
Application layer vs domain layer?
I am reading Domain-Driven Design by Evans and I am at the part discussing the layered architecture. I just realized that application and domain layers are different and should be separate. In the project I am working on, they are kind of blended and I can't tell the difference until I read the book (and I can't say it's very clear to me now), really.

My questions, since both of them concerns the logic of the application and are supposed to be clean of technical and presentation aspects, what are the advantages of drawing a boundary these two?

答:
Domain Layer should be designed as an isolation layer, which means the business logic and rules should not be affected with any codes (in Application Layer, Presentation Layer and Infrastructure Layer) changes.

Application Layer is suppose to be designed to provide some functions about what a system (application) interface (think this like an API or RESTful) can do. For example, users can log in a system, and in this application action (login), application layer codes will be the client codes for Domain Layer (or Infrastructure Layer), in which retrieves User domain object and apply this object's methods to implement the 'login' function.

Application Layer should also be designed as an isolation layer, which means the application's behaviours should not be affected with any codes (in Presentation Layer, Domain Layer and Infrastructure Layer) changes.

Title: Application layer vs domain layer?


问:
Efficient Summary calculation method or approach?
I have an object hierarchy with a number of leaf nodes that will contribute to summary values for the parent object (specifically: project cost and square footage).

What's the most efficient way to tally up those values while the project is being designed?

Additional details

```<code> Parent
   ListOne
     NodeA
       NodeA.1
       NodeA.2 ...
     NodeB
       NodeB.1
       NodeB.2 ...
   ListTwo ...
</code>```

There will only be one dot-# leaf node selected at a time, so it will be either NodeA.1 OR NodeA.2 but not both being selected.

Whether or not NodeA and NodeB are selected are independent of each other.  So I could have any combination of selected / active Nodes A -> Z

One approach is simply to iterate through each List, each Node, and each Leaf Node and only sum the values when the leaf node is selected.

Another approach would be to create an event handler for the parent project variables that each child can then fire against when their values change.  The wrinkle here is that I'll have Node specific values that I'll want to track as well.  In other words, I'm tracking Project Cost, List Cost and Node Cost.

Another approach would be a hierarchy of event handlers that fire as the selected item changes and then notify their parent of the change.  So the change in a leaf node would eventually cascade back up to the Project after a number of events having been fired.

Right now, the overall project structure is pretty small - only three or four Lists, each with about six Nodes that have four to six Leaf Nodes each.  Because of the smaller size, I'm not worried as much about computation time as I am about maintaining this and being able to extend it in the future as more Lists, Nodes, etc... are added.

Edit:

The project driving this question is written in C# and actually has one more layer between the List and the final leaf nodes.  I think the question is relevant to C++ and Java programmers since it's dealing with the responsibilities between children and parent objects when a value of the parent depends upon its children and grand-children.  An answer tailored to C# would be gravy, but I'm looking for the most robust / maintainable approach in this case.

答:
The simplest (easiest to understand, read, and maintain) is to simply define, in the parent:

```<code>public int Summary
{
    get { return this.Children.Sum(x => x.SomeVariable); }
}
</code>```

If you don't have a performance problem (and it sounds like you don't), I'd do that.  If you're worried about updating the display of a parent node when a child node changes, there are two simple alternatives:

Use a timer and just recalculate every X seconds (assuming the recalculate time << X), or

Use a message bus of some kind.  Inject the message bus object into all nodes.  When any node changes something that a parent might care about, send a message, and have that message trigger a refresh as necessary.

I tried events once, and if you're actively adding and removing nodes, it gets messy because if you don't properly unsubscribe from each event when a node is removed, you could get dangling references, and the equivalent of a memory leak.

Body:
The simplest (easiest to understand, read, and maintain) is to simply define, in the parent:

public int Summary
{
    get { return this.Children.Sum(x => x.SomeVariable); }
}

If you don't have a performance problem (and it sounds like you don't), I'd do that.  If you're worried about updating the display of a parent node when a child node changes, there are two simple alternatives:

Use a timer and just recalculate every X seconds (assuming the recalculate time << X), or

Use a message bus of some kind.  Inject the message bus object into all nodes.  When any node changes something that a parent might care about, send a message, and have that message trigger a refresh as necessary.

I tried events once, and if you're actively adding and removing nodes, it gets messy because if you don't properly unsubscribe from each event when a node is removed, you could get dangling references, and the equivalent of a memory leak.


答: Unless this list will contain millions of entries, just do the simplest thing: iterate and sum.  Save anything more complicated until the simple code is measurably too slow.

Title: Efficient Summary calculation method or approach?

Body:
I have an object hierarchy with a number of leaf nodes that will contribute to summary values for the parent object (specifically: project cost and square footage).

What's the most efficient way to tally up those values while the project is being designed?

Additional details

```<code> Parent
   ListOne
     NodeA
       NodeA.1
       NodeA.2 ...
     NodeB
       NodeB.1
       NodeB.2 ...
   ListTwo ...
</code>```

There will only be one dot-# leaf node selected at a time, so it will be either NodeA.1 OR NodeA.2 but not both being selected.

Whether or not NodeA and NodeB are selected are independent of each other.  So I could have any combination of selected / active Nodes A -> Z

One approach is simply to iterate through each List, each Node, and each Leaf Node and only sum the values when the leaf node is selected.

Another approach would be to create an event handler for the parent project variables that each child can then fire against when their values change.  The wrinkle here is that I'll have Node specific values that I'll want to track as well.  In other words, I'm tracking Project Cost, List Cost and Node Cost.

Another approach would be a hierarchy of event handlers that fire as the selected item changes and then notify their parent of the change.  So the change in a leaf node would eventually cascade back up to the Project after a number of events having been fired.

Right now, the overall project structure is pretty small - only three or four Lists, each with about six Nodes that have four to six Leaf Nodes each.  Because of the smaller size, I'm not worried as much about computation time as I am about maintaining this and being able to extend it in the future as more Lists, Nodes, etc... are added.

Edit:

The project driving this question is written in C# and actually has one more layer between the List and the final leaf nodes.  I think the question is relevant to C++ and Java programmers since it's dealing with the responsibilities between children and parent objects when a value of the parent depends upon its children and grand-children.  An answer tailored to C# would be gravy, but I'm looking for the most robust / maintainable approach in this case.


问:
Surviving MATLAB and R as a Hardcore Programmer
I love programming in languages that seem geared towards hardcore programmers.  (My favorites are Python and D.)  MATLAB is geared towards engineers and R is geared towards statisticians, and it seems like these languages were designed for people who aren't hardcore programmers and don't think like hardcore programmers.  I always find them somewhat awkward to use, and to some extent I can't put my finger on why.  Here are some issues I have managed to identify:

(Both):  The extreme emphasis on vectors and matrices to the extent that there are no true primitives.

(Both):  The difficulty of basic string manipulation.

(Both):  Lack of or awkwardness in support for basic data structures like hash tables and "real", i.e. type-parametric and nestable, arrays.

(Both):  They're really, really slow even by interpreted language standards, unless you bend over backwards to vectorize your code.

(Both):  They seem to not be designed to interact with the outside world.  For example, both are fairly bulky programs that take a while to launch and seem to not be designed to make simple text filter programs easy to write.  Furthermore, the lack of good string processing makes file I/O in anything but very standard forms near impossible.

(Both):  Object orientation seems to have a very bolted-on feel.  Yes, you can do it, but it doesn't feel much more idiomatic than OO in C.

(Both):  No obvious, simple way to get a reference type.  No pointers or class references.  For example, I have no idea how you roll your own linked list in either of these languages.

(MATLAB):  You can't put multiple top level functions in a single file, encouraging very long functions and cut-and-paste coding.

(MATLAB):  Integers apparently don't exist as a first class type.

(R): The basic builtin data structures seem way too high level and poorly documented, and never seem to do quite what I expect given my experience with similar but lower level data structures.

(R): The documentation is spread all over the place and virtually impossible to browse or search.  Even D, which is often knocked for bad documentation and is still fairly alpha-ish, is substantially better as far as I can tell.

(R):  At least as far as I'm aware, there's no good IDE for it.  Again, even D, a fairly alpha-ish language with a small community, does better.

In general, I also feel like MATLAB and R could be easily replaced by plain old libraries in more general-purpose languages, if sufficiently comprehensive libraries existed.  This is especially true in newer general purpose languages that include lots of features for library writers.

Why do R and MATLAB seem so weird to me?  Are there any other major issues that you've noticed that may make these languages come off as strange to hardcore programmers?  When their use is necessary, what are some good survival tips?

Edit:  I'm seeing one issue from some of the answers I've gotten.  I have a strong personal preference, when I analyze data, to have one script that incorporates the whole pipeline.  This implies that a general purpose language needs to be used.  I hate having to write a script to "clean up" the data and spit it out, then another to read it back in a completely different environment, etc.  I find the friction of using MATLAB/R for some of my work and a completely different language with a completely different address space and way of thinking for the rest to be a huge source of friction.  Furthermore, I know there are glue layers that exist, but they always seem to be horribly complicated and a source of friction.

答:
I work with MATLAB, Python and C (and sometimes C++), and I consider myself to be (primarily) a software developer, sitting opposite colleagues who tend to be data scientists, mathematicians, or other domain specialists.

Although I would be the first to admit that it is not a general purpose programming language in the sense that C or Python is, I actually enjoy writing scripts in MATLAB rather a lot, particularly for things like time-series analysis or image processing.

There are a couple of features of the language which, although generally implemented quite inefficiently, are a joy to use. For example, take logical indexing: I can create a logical vector or matrix that selects a region-of-interest, and name it "isInROI", performing a filter operation to select elements from the vector or matrix "data" in that region is then simply a matter of writing: "roiData = data(isInROI)".

It is moments like this that really make me appreciate MATLAB, and allow me to overlook its other, numerous and much-discussed sins.


问:
Is the time spent customizing your dev machine environment worth it?
There are times when I am working on programming project and I get the itch to change some stuff in my environment (OSX or Linux). Vim might not being doing exactly
what I want, so instead of doing it the round about way I've been doing for a
couple months (sometimes years) I go and figure out the right way. Or I may be
doing something long handed in bash and I say to myself why don't I figure out
a better way.

The thing is when I go off and do this hours can fly by. Sometimes I
get stuck on trying to get what I want. I'll know I'm really close, so I don't give
up. I usually always get it eventually, but its after hours of tinkering and
googling. I hate the feeling of giving up and having to deal with something I
know could work better.

When I'm done I have a warm feeling knowing that my environment is a little more smooth
and personalized, but I wonder could my time be better spent. Where do I draw
the line? It seems with the all the UNIX-style tools there is an endless amount
to learn.

Always thought the sign of a superior programmer is someone who goes out of
their way to make the computer bend to their will. Am I doing it right? I figure
the bash shell, unix/linux, and vim will be around forever, so I see it as an investment.

But then again I just spend 3 hours trying to get some stupid thing the vimperator firefox
plugin to work right.

So I wondering what this community think about this.

答:
See Yak shaving, aka "Shaving the Yak".

A development environment has to be personalized to some extent, because we are all unique individuals who think differently. Some of us use vim, some use eclipse, the crazies use emacs :-), but we have to do some tweaking to get the plugins, the colors, and the shortcuts as we like them. I use vim, so I install my favored developer font (Dejavu Sans Mono) and my .vim, .vimrc and .gvimrc from my home machine, and I'm 90% done. The rest is setting up aliases or my command-line settings.

It's well known that we periodically need to take a mental break so if you can fit in tweaks in those 10-15 minute pauses nobody should complain. Plus I feel good when I get a tweak in and can immediately start working with it.


问:
Should we ever delete data in a database?
I am new to databases and trying to understand the basic concepts. I have learned how to delete data in a database.  But one of my friends told me that you should never delete data in a database.  Rather, when its no longer needed, it's better to simply mark it or flag it as 'not in use'.

Is that true? If so, how would a big company like IBM handle their data for a hundred or more years?

答:
As with all these things the answer is "it depends".

If the user is ever likely to want the data back then your friends are right - you don't really delete just mark the record as "deleted". This way when the user changes their mind you can recover the data.

However, if the deleted data is more than a certain time period old (a year for example) you might decide to really delete it from the live tables but keep it in either an archive table or even just on back up should the user ever want it back. In this way you can keep the amount of data (live and recently deleted) to a minimum.

However, if the data is ephemeral or easily recreated you may well decide to actually delete the data.

There is one class of data that you have to delete - and that's personal data that the user doesn't want you to hold any more. There may be local laws (e.g. in the EU) that makes this a mandatory requirement (thanks Gavin)

Equally there may be rules that require you not to delete data, so before deciding anything check with any regulatory authorities on what you need to do to comply with the law.


问:
Is it possible to call a Javascript function from C?
I'd like to find a way to call Javascript functions from C. Are there any language bindings available for this purpose? I'm trying to make a library of Javascript functions accessible from C. (Something like a C -> Javascript foreign function interface would be suitable for this purpose, but I haven't been able to find one so far.)</p>

答:
There's quite a few Javascript engines you can use.  Which one makes most sense will largely depend on your specific platform/target environments/needs.

There's the V8 javascript engine that powers Chrome, and Firefox's SpiderMonkey.

If Windows-only would suffice, you can use Active Scripting (IActiveScript site and other interfaces).   A number of my Windows applications do this.

If QT, I believe they have their own JavaScript classes that can be accessed.

Thats not an exhaustive list, I'm sure there are others.  But that should get your search started.


答:
I generally don't remove user data in my databases.  I flag them to be hidden.  All too often a user deletes something accidentally and needs it replaced easily.  It also helps retain referential integrity for related data.  This works for small to moderate size databases.  In systems where performance is heavily impacted by this decision it's handled in special ways, e.g. archive tables, automated backups, etc.

We do discard backend data as necessary, e.g. expired web site session data and old log infomation.  There's no point at all in keeping them forever.

As usual, though, the exact answer really depends on the specific situation.

Title: Should we ever delete data in a database?

Body:
I am new to databases and trying to understand the basic concepts. I have learned how to delete data in a database.  But one of my friends told me that you should never delete data in a database.  Rather, when its no longer needed, it's better to simply mark it or flag it as 'not in use'.

Is that true? If so, how would a big company like IBM handle their data for a hundred or more years?


问:
Is there ever a reason to do all an object's work in a constructor?
Let me preface this by saying this is not my code nor my coworkers' code. Years ago when our company was smaller, we had some projects we needed done that we did not have the capacity for, so they were outsourced. Now, I have nothing against outsourcing or contractors in general, but the codebase they produced is a mass of WTFs. That being said, it does (mostly) work, so I suppose it's in the top 10% of outsourced projects I've seen.

As our company has grown, we've tried to take more of our development in house. This particular project landed in my lap so I've been going over it, cleaning it up, adding tests, etc etc.

There's one pattern I see repeated a lot and it seems so mindblowingly awful that I wondered if maybe there is a reason and I just don't see it. The pattern is an object with no public methods or members, just a public constructor that does all the work of the object.

For example, (the code is in Java, if that matters, but I hope this to be a more general question):

public class Foo {
  private int bar;
  private String baz;

  public Foo(File f) {
    execute(f);
  }

  private void execute(File f) {
     // FTP the file to some hardcoded location,
     // or parse the file and commit to the database, or whatever
  }
}
```
<p>If you're wondering, this type of code is often called in the following manner:</p>
<pre class="lang-java prettyprint-override"><code>for(File f : someListOfFiles) {
   new Foo(f);
}
</code>```

Now, I was taught long ago that instantiated objects in a loop is generally a bad idea, and that constructors should do a minimum of work. Looking at this code it looks like it would be better to drop the constructor and make execute a public static method.

I did ask the contractor why it was done this way, and the response I got was "We can change it if you want". Which was not really helpful.

Anyway, is there ever a reason to do something like this, in any programming language, or is this just another submission to the Daily WTF?

答:
No.

If all the work is done in the constructor it means the object was never needed in the first place.  Most likely, the contractor was merely using the object for modularity.  In that case, a non-instantiated class with a static method would have gained the same benefit without creating any superfluous object instances.

There is only one case in which doing all the work in an object constructor is acceptable.  That is when the purpose of the object is specifically to represent a long term unique identity, rather than perform work.  In such a case, the object would be kept around for reasons other than performing meaningful work.  For example, a singleton instance.

ContentLicense: CC BY-SA 4.0


答:
This is actually a significant problem for a lot of companies.  There's no way to cleanly determine what data is actually in use, so it just sits in the database.  Data deletion and archiving needs to be a part of every large system design, but it rarely is.  Most companies just live with it, buying bigger disks and tweaking their queries and indexes to maintain performance, until they change systems and then they go through a significant amount of effort to identify current data and then only migrate those records to their new system.

Yes, you should delete data from your database, but it's often not simple to tell what and when.


问:
Strategy for writing a logic program
I have had a hard time learning logic programming thus far, and my request for outside resources on this site was met with some opprobrium, so perhaps this question better addresses both my needs and the requirements of this community:

Is there a step-by-step approach to writing a problem in Prolog or related logic languages? For example, I initially found recursive functions difficult to create myself, though I could more or less understand those that I read, until the I learned the following approach (presented roughly and for example purposes only!):

Describe the base case, i.e. the smallest form of the problem.

Figure out how to combine the results of recursive cases, i.e. add numbers, cons elements, etc. Seeing that there were a few common patterns here helped immensely!

Figure out how to break the results of a larger recursive case up, i.e. cdr down list, subtract, etc. Again, seeing the limited number of common patters was key!

So, a clear description of a related process for tackling a logic problem might be very useful.

答:
Hmmm, let's see. The most fundamental elements of programming languages are state, control flow, and computation. Logic programming subsumes much of this in a single very powerful operation: unification.

Instead of state (global variables) that is changed via assignments, is emphasizes local, single-assignment variables that receive values through unification with other structures. Control flow is expressed through keywords like if or while; but Prolog only has a general unification rule operator (:-) that defines when to attempt unification, and of what. Instead of loops with while, you typically use predicates calling themselves; this gives similar results as loops, and with some care is just as efficient (although more confusing to many learners). Even the most basic control flow - sequencing of operations - is technically not a sequencing construct, but a logical AND operator (,) which just happens to guarantee left-to-right evaluation. Finally, computation is also usually performed by unification rather than by operators, e.g. for list operations or destructuring binds. Even arithmetic can be done through unification if you use Peano numbers, although this is admittedly cumbersome, and Prolog also has an escape hatch into normal arithmetic evaluation with is (but this breaks referential transparency and goes somewhat against the spirit of the system).  Most nontrivial Prolog program use many or all of these elements.

Take the simple 'reverse a list' task: almost all solutions you ever see use unification in place of the "if"s you would use in other languages, destructuring bind to manipulate the lists, recursion to generalize from a one-element list to arbitrary lists, and , to sequence the recursive step and the combination step. In the final analysis, they still use the fundamentals of computing such as "IF" or "A, THEN B", but they are all expressed in the medium of terms combined via unification, given arbitrary power through recursion. It is in fact surprisingly difficult to find an instructive predicate that doesn't use recursion in some way. If you have an example of a problem that you can't see how to solve at all, by all means please post it.

Title: Strategy for writing a logic program


问:
How to properly design classes for a big project?
If we need to represent classes in a class diagram for a big project that is not completely designed yet, and the classes have to be actual tables in a database, how would we predict and design the classes?

Let's say we have a project that is going to have more than 15 tables, do all these tables need to be classes in the class diagram?

How would classes be designed in this kind of situation? The language that is being used is Java and the class diagram has to prepared in UML. I know how to design them, I just don't know if the tables should represent the classes in this case.

答: In general, I would say no.  You should consider having a DTO class that mirrors the table's structure, but its only use is for transferring data.  There should be other classes in your persistence layer that support the particular functions your application needs (e.g., you might have a Customer class that contains multiple Address instances, so it would make sense that getting a Customer will require that you also get any associated Addresses.  All the data access should be done from your DAO or manager classes, so all your application has to worry about is creating or using a Customer).  If your business logic has to worry about what table some data is stored in, you're doing it wrong.


问:
What is volume in terms of databases?
I was reading a text. It said,

```<code>"Information presentation must be compatible with the response time needs of
systems. The response time should be short enough that the information  does not
lose its freshness and value but it should be long enough to reduce volume (and
costs) and reveal important trends that signal the need for action"
</code>```

What does volume mean in it? Please help out. Thanks

答:
Volume in this context simply means size and amount of data.

Low volume = less data

More volume = more data

Title: What is volume in terms of databases?


问:
Would this constitute MVC - even in a very loose sense?
I've been working on a kind of CRM for the sales guys in our office - not as a job role but as a spare time task type of thing - I don't claim to be a developer or anything like that, but I would definitely like to pursue a career as a web developer down the line, I just think I need a much stronger understanding of OOP principles and design patterns such as MVC before I could even consider it.

Basically the way I've developed it each section of the App is a html page, that uses jQuery to listen for events, which then sends ajax requests to the server, which are then redirected to class methods that will perform usually simple CRUD tasks, and send back a JSON response to the client which will then be reflected on the page - would that constitute mvc even in a loose sense, as presentation is completely seperate from things like database interaction and theres a go-between to interact between the two?

Like I say i'm in the very early stages of grappling the comprehension of MVC as a whole so any thoughts would be appreciated, thanks.

答:
Certainly sounds like a good design and not a million miles from MVC.

sends ... requests to the server, which are then redirected to class methods

This is how a controller works in MVC. It is unclear, from your description, whether your model is separated from the controller. If the controller then passes its CRUD operations onto another class (eg. Customer.update(customerData)), and simply handles the request-response action then I would suggest you probably have the M and C in place -- albeit in a simplistic way.

each section of the App is a html page, ... and send back a JSON response to the client

Those are two common view types in MVC frameworks. And you've certainly created that level of abstraction, which is great.

Nowadays there are expectations of an MVC framework that don't necessarily fall into the MVC pattern. For example, to make it a "proper" MVC framework, you'd have to be able to return data from the controller, along with an indicator of which view type (and perhaps view template) you want the framework to build from that data.

So I would say that you've not necessarily created an MVC framework but you are following something approximating the MVC pattern.

Perhaps a more accurate term for what you're doing though is SOA or service-oriented architecture.


答:
I've certainly created many classes that do a lot of work to calculate something in the constructor, but the object is immutable, so it makes the results of that computation available via properties, and then never does anything else.  That's normal immutability in action.

I think the weird thing here is to put code with side effects into a constructor.  Building an object and throwing it away without accessing the properties or methods looks weird (but at least in this case it's pretty obvious that something else is going on).

This would be better if the function was moved to a public method, and then have an instance of the class injected, then have the for loop call the method repeatedly.

Title: Is there ever a reason to do all an object's work in a constructor?

Body:
Let me preface this by saying this is not my code nor my coworkers' code. Years ago when our company was smaller, we had some projects we needed done that we did not have the capacity for, so they were outsourced. Now, I have nothing against outsourcing or contractors in general, but the codebase they produced is a mass of WTFs. That being said, it does (mostly) work, so I suppose it's in the top 10% of outsourced projects I've seen.

As our company has grown, we've tried to take more of our development in house. This particular project landed in my lap so I've been going over it, cleaning it up, adding tests, etc etc.

There's one pattern I see repeated a lot and it seems so mindblowingly awful that I wondered if maybe there is a reason and I just don't see it. The pattern is an object with no public methods or members, just a public constructor that does all the work of the object.

For example, (the code is in Java, if that matters, but I hope this to be a more general question):

public class Foo {
  private int bar;
  private String baz;

  public Foo(File f) {
    execute(f);
  }

  private void execute(File f) {
     // FTP the file to some hardcoded location,
     // or parse the file and commit to the database, or whatever
  }
}
```
<p>If you're wondering, this type of code is often called in the following manner:</p>
<pre class="lang-java prettyprint-override"><code>for(File f : someListOfFiles) {
   new Foo(f);
}
</code>```

Now, I was taught long ago that instantiated objects in a loop is generally a bad idea, and that constructors should do a minimum of work. Looking at this code it looks like it would be better to drop the constructor and make execute a public static method.

I did ask the contractor why it was done this way, and the response I got was "We can change it if you want". Which was not really helpful.

Anyway, is there ever a reason to do something like this, in any programming language, or is this just another submission to the Daily WTF?


答:
Oded is right, but in the case of databases, this can mean not just the amount of data that you return, but also the number of queries or requests it takes to get there.

This text appears to be talking about performance of a chatty information dashboard. The tradeoff is always "OK, do I grab a bunch of data up front and save making lots of requests, or do I get the data up as quickly as possible by using small requests that return limited portions of the dashboard".

Your needs will vary, depending on the application.

Title: What is volume in terms of databases?

Body:
I was reading a text. It said,

```<code>"Information presentation must be compatible with the response time needs of
systems. The response time should be short enough that the information  does not
lose its freshness and value but it should be long enough to reduce volume (and
costs) and reveal important trends that signal the need for action"
</code>```

What does volume mean in it? Please help out. Thanks


问:
Working on multiple things at work?
I was curious to know, if juggling between 2-3 projects at a time is a good or a common practice or not. When I say, 2-3 projects I mean:

1. 1 primary project,

2. 1 project with minor improvements/changes and

3. 1 project which comes at times for bug fixes

So essentially, I find my self generally working on 2 projects in parallel and sometimes the 3rd one comes in with a trivial fix.

Is this a problem? Or I should be learning to work on multiple projects at any given time. My personal opinion is, this style of work might affect how detailed and in-depth you think about a project.

答:
This can become an issue if you have problems switching contexts between projects. From what I understand, it takes about 15 minutes to reach "full work mode". Working on more than 1 project is common in most workplaces, though it's a bad idea to exagerate. 2 or 3 projects is probably ok, but only as long as you don't have to work many extra hours. Enough man-power in the company is needed if this becomes an issue.

If you find yourself in this kind of position, I recommend not to work on more than 1 project per day. This way, you can remain fully focused at what you do and maintain optimal productivity.

I know someone who had to work on 5 different projects at once. He always had to switch between them because clients kept requesting specific bug fixes every day. The management didn't hire extra developers to help out, so he quit. It was the best decision possible.

Title: Working on multiple things at work?


问:
How have languages influenced CPU design?
We are often told that the hardware doesn't care what language a program is written in as it only sees the compiled binary code, however this is not the whole truth. For example, consider the humble Z80; its extensions to the 8080 instruction set include instructions like CPIR which is useful for scanning C-style (NULL-terminated) strings, e.g. to perform strlen(). The designers must have identified that running C programs (as opposed to Pascal, where the length of a string is in the header) was something that their design was likely to be used for. Another classic example is the Lisp Machine.

What other examples are there? E.g. instructions, number and type of registers, addressing modes, that make a particular processor favour the conventions of a particular language? I am particularly interested in revisions of the same family.

答:
As far as I know this was more common in the past.

There is a session of questions in which James Gosling said that there were people trying to make hardware that could deal better with JVM bytecode, but then these people would find out a way to do it with common "generic" intel x86 (maybe compiling the bytecode in some clever way).

He mentioned that there is advantage in using the generic popular chip (such as intel's) because it has a large corporation throwing huge sums of money at the product.

The video is worth checking out. He talks about this at minute 19 or 20.


答:
It depends on what you mean as 'juggling'.

If you by juggling you mean:

Work on project 1 for an hour

Work on project 2 for an hour

Work on project 1 for 15 minutes

Work on project 2 for 30 minutes, etc...

That is BAD.  It is a widely quoted that it can take 15 minutes to regain your focus after being disrupted.

This means that in the above example you worked for 2:45 and you had 4 periods of 15 minutes to get 'flowing', wasting an hour.  That is wasting 36% of your time.

If you mean juggling:

Work on project 1 for 5 hours

Work on project 2 for 3 hours

This is acceptable.

The more you are able to work on the same project for longer blocks of time, the less time wasted getting the project into your brain.

I believe most programmers must work on multiple projects so yes, you should be able to work on multiple projects, just not constantly switching between the different them.

Title: Working on multiple things at work?

Body:
I was curious to know, if juggling between 2-3 projects at a time is a good or a common practice or not. When I say, 2-3 projects I mean:

1. 1 primary project,

2. 1 project with minor improvements/changes and

3. 1 project which comes at times for bug fixes

So essentially, I find my self generally working on 2 projects in parallel and sometimes the 3rd one comes in with a trivial fix.

Is this a problem? Or I should be learning to work on multiple projects at any given time. My personal opinion is, this style of work might affect how detailed and in-depth you think about a project.


答:
I (unfortunately) generally have to do this. I have had the same job for a long time (15+ years) so I don't have the benefit of working at several places. It can very frustrating and certainly doesn't help reduce stress or bugs. I recall reading somewhere, might have been Code Complete, that it takes 30 minutes to mentally switch tasks. If I can find a link, I'll edit the post.

In my situation, it's worse when one project is starting and another ending. That tends to be anywhere from 2-10 days of constant back and forth.  Make a little progress on new, fix and/or refactor old, rinse and repeat.

I think the random, minor fix for is something we just have to deal with, life happens.

One thing you can try when your plate is full of 2 (or more) constant projects is the pomodoro technique.

Another is to try and reason w/ management by explaining you are a single core and well designed for constant multitasking.

Title: Working on multiple things at work?


问:
The perfect crossfade
I find it hard to describe this problem in words, which is why I made a video (45 seconds) to illustrate it. Here's a preview of the questions, please have a look at it on Vimeo: http://vimeo.com/epologee/perfect-crossfade

The issue of creating a flawless crossfade or dissolve of two images or shapes has been recurring to me in a number of fields over the last decade. First in video editing, then in Flash animation and now in iOS programming. When you start googling it, there are many workarounds to be found, but I really want to solve this without a hack this time.

The summary:

What is the name of the technique or curve to apply in crossfading two semi-transparent, same-colored bitmaps, if you want the resulting transparency to match the original of either one?

Is there a (mathematical) function to calculate the neccessary partial transparency/alpha values during the fade?

Are there programming languages that have these functions as a preset, similar to the ease in, ease out or ease in out functions found in ActionScript or Cocoa?

Update: In addition to the video, I've made a sample project (requires Xcode and iOS SDK) and posted it on github. It shows the same animation as the video but this time with squares: https://github.com/epologee/StackOverflow-Example-Code

答:
I am afraid that's not possible.
This is how transparency is calculated when two objects overlay:
http://en.wikipedia.org/wiki/Alpha_compositing

One of the objects must have an opacity of 1 if you don't want the overlay area to be seen through.

Title: The perfect crossfade


答:
In my current job I very often find myself switching between 2-3 projects, mostly because a main project will be long term, and will require others to sign off on parts, test parts and write requirement for parts before I can continue, so I grab bug fixes to do in between.

It's fine so long as you make sure to clear the rest of the stuff out of your mind (and your windows onscreen), although our boss is trying to move away from it (hopefully by hiring more developers/BAs/testers)

Title: Working on multiple things at work?


答:
I'm not sure where you draw the line to indicate I've gone from one project to another. This whole "it takes 15 minutes..." seems to be overly applied. Now that I am familiar with a couple of our databases, I can switch from one to another very easily. Now just because I am on the same "project" and switch from the database to working on the UI, I'm not sure there is a lot of continuity there. Being in the same domain has its advantages.

All problems don't require the same level of concentration. Working on 3 new projects all at the same stage could get confusing. Sometimes working on a different project can get me motivated, so there can be advantages if it allows you to avoid boredom.

Title: Working on multiple things at work?


答: That's how it's been at all the places I've worked.  Actually, only having 2-3 active projects at a time would be a significant decrease.  :-)  I suppose it's due to working at places with real small IT groups where it's much harder to specialize.</p>

Title: Working on multiple things at work?


问:
Is it common to separate back-end and front-end into two positions on web development projects?
At a web startup, is it more common to have an engineer working the front-end AND back-end of the feature (basically in charge of the whole feature)? Or have engineers separated between the back-end and front-end?

Which ones are more beneficial and for what situations?

The downside, I've noticed, regarding having one engineer in charge of the whole feature is that the person might only be particularly strong in either frontend or backend development but not both, thus sometimes having a decrease in speed and quality.

Having frontend and backend developers on one feature increase the speed of the feature and the quality AND it encourages collaboration. But I am concerned about having 2 engineers working on one feature which may be a poor use of resources since the 1 engineer can be placed on another feature to work on.

What is the common/best practice for allocation backend/frontend engineering resources at a small early-stage startup? And then how will it change as it grows?

答:
The best answer is from @Shark, but only the last part "It depends."  In my experience, ~16 years or so, I've seen both options attempted in a variety of different configurations.  Being a full stack developer myself, here's what I've come to learn:

*(BE = Back End, FE = Front End)

General Caveats Of Split Stack Development:

Agile development practices (a common strategy these days) recommends feature development, where the feature is a single valuable chuck of functionality from the customer's perspective.  From this perspective you should have your developer implement both.

Splitting the stack along the server boundary creates an integration point between the two developers.  Unless they communicate effectively and work well together this will cause a fair number of bugs when the two features come together.

Apply the n(n-1)/2 rule of communication from the Mythical Man-Month and you will see that splitting features in two parts between two people will increase your overall workload.  Granted that rule applies to features as well, but spliting the stack doubles the amount of communication.

A designer will solve the problems of BE developers not being able to produce attractive interfaces from scratch. This assumes they at least know html & css and can produce an interface that matches the screenshots created by the designer.

Features are typically isolated components that interact very little with other features. This is not always the case but usually the point of interaction is at a low level like a database or filesystem.  So there isn't much preventing a full-stack developer from implementing their feature.  But if an FE developer has to wait on a BE developer to finish a task, it will add even more delay on top of the productivity loss in point 3.

Web2.0 blurs the distinction between FE & BE even further.  With MVC frameworks, and entire applications being built on the client-side, a good deal of BE knowledge is now required to implement secure and efficient FE applications.

My biggest gripe towards this practice is that it limits the abilities of everyone involved on the project.  Although this was a common practice in the early 2000's it was done out of necessity because finding developers that could do both was pretty difficult (purely because of new-ness not because of some intrinsic difficulty in learning both.)  What remains of the practice is a decade later we still have "web developers" that don't know CSS.

My second biggest gripe is that it can easily segment a development team.  A FE developer creates a bug after modifying BE code and the team votes to restrict cross-stack development wholesale.  Whereas code reviews and education could solve the problem, people become territorial instead.

Benefits/Use-Cases of Split Stack Development:

RESTful API's are perfect for this delineation because there is no FE.  Often a company will work on a RESTful API first, and then develop their web applications on top.  In this case there is a strong case for keeping the BE team focused on the next major version while the FE is finishing the application.  But the danger of churn still exists - especially if new information discovered in the FE dev phase requires non-trivial modifications to the BE API.

Unbalanced workloads between FE & BE are also a good case for creating a FE only team.  Again this is very situational where perhaps the main development is done via a desktop application and the company is trying to develop a 'lite' web interface.

Training new/junior developers.  If you are hiring an intern or a junior dev and are concerned about throwing them into the deepend, it's a good option to invest some of that communication/integration cost into a peer development system.

Concerns about @Ralf's accepted answer on this page:

The first point is pretty bold - and it will fail quickly if you don't have one of those "good self-organizing teams".  Even if you have that team, it's in your and their interests to push their boundaries.  And good self-organizing teams are not always self-motivated to do that.

Your second point is just wrong.  Modern web development requires FE code that is performant, secure, asynchronous safe, XSS-proof, cross-browser, and developed quickly.  The goals simply do not compete with BE they are effectively equal.

The third point is also a bad assumption - FE development can begin with pure html/css/js without any BE foundation work.  From there it's only a trivial effort to break it down into templates for BE rendering.  Often times it's best to start with FE work because it will give stakeholders a warm & fuzzy feeling to see visual progress up front.

Conclusion:

If you are a startup and you don't happen to have a lot of time or money to burn, then don't hire FE or BE only developers.  Hire senior level web developers and a good ux/designer, and they will get your application off the ground as quickly as possible.  They cost more, but they are far more productive and you'll need fewer of them.


问:
Comparing one's self to others during interviews
I'm often asked at some point during the interview process to compare myself to my peers.  For example, one of my first after-graduation jobs asked me to compare myself to my classmates.  A job I recently interviewed for asked me to compare myself to my coworkers.

I always play this down quite a bit.  I'm always worried that, "I'm miles above everyone around me," sounds too arrogant.  When push comes to shove though it is the truth.

I graduated at the top of my class.  I had a 3.99, the highest GPA of anyone else that year.  My fellow students bitched and moaned about things like having to use the console to write "javac xxx.java" and build programs instead of just hitting the build button in VS.  Most of them were utterly inept and I'd hate to see what happened to them in the real world.  Others were miles above these people.  There were like 3-5 of us that actually gave a damn, pursued our own education as if it mattered, and had whatever genes are necessary to think like a programmer or mathematician (the one guy I'd say was smarter than me was actually a math major--he graduated one year ahead of me or he would have taken my title).  Even among these few "big hitters" I was one of, if not the best (some was due to more experience though).

For about 90% of the other students though I see this not as me being so good, but them being really that f'n bad.  I was often dumbfounded not just by their ignorance, but by their unwillingness to do what it took to loose it.  My peers in college were lazy, bemoaning, irresponsible, sacks of stupidity that would rather run around puking from so much booze than put out the least amount of effort in learning anything.  Then they blamed their ineptitude on the professors.

As I entered the workforce I found that this trend continued.  When I'm on the internet, talking to a worldwide populace of brilliant people I'm rather mediocre.  I'm smart, excited, etc...I'm still very good but I'm much more able to see myself as a smaller fish in a larger ocean.  Locally though, in personal real life experience....what I find easy others find hard even among what I'd call some of the best developers I've worked with.  I know more about design, general development, and the specific language I use more than anyone else I know.  Part of this is, I know full well, the kind of places I've learned in and where I've worked (who doesn't have the money to pay me what I'm worth).  Still though, if I were to fairly compare myself to my coworkers, and in years past my co-students...don't I come off as more than a little arrogant?

Others see me this way too though.  It actually took me a while to recognize that there's actually something significantly special about the way I approach my programming (I really care), work ethic, and additionally my lucky roll in the gene game.  I have seen it get to my head from time to time, and I try to avoid it, but in all honesty I'm just better than most.

One thing that seems to differentiate me more than anything really is the fact that I continue to pursue greater knowledge at home, off hours.  I'm one of the best because I want to be and it shows significantly.  I've found that this is actually fairly rare in the real world, though many Internet people have me beat here as well.

Knowing that there's certainly many more people like this out there, in fact I know of many people on SE that are much smarter than I am, how do you approach this question?  Do you answer honestly?  "I'm a fucking God that has do dumb down everything thing they do for the little people!  The only way I can drag the rest along is by saying everything 20 times in 5 different ways."  Or do you downplay yourself to make sure you don't come off as someone so damn arrogant they can't work with others?

Edit: Yes, I make grammatical mistakes and additionally many more.  I also suck at welding even though I tried very hard to get it.  I also have a very hard time keeping my house plants alive.  Some people are simply better at it.  I'm simply better at programming.

答: I would simply describe the Dunning-Kruger effect, a cognitive bias which makes it essentially meaningless to effectively compare yourself to others.</p>


问:
Storing plaintext passwords for detecting fraud
I am well aware of best practices for storing user passwords:

Never store passwords in plaintext

Never store encrypted passwords; always store password hashes

Always salt your password hash to deter brute force attacks

Always use unique salts to deter attacks using rainbow tables.

However, I have recently came upon on a potentially legitimate use case for keeping plaintext (or plaintext-accessible encrypted) user passwords: fraud detection. For example, if we have a system that needs to restrict purchases to 1 (or a small number) per person, we have observed that fraudsters often use the same password over and over, so if we have detected fraudulent purchases on one account, we can use the fact that password matches as a useful signal in a fraud detection system.

But implementing such a system requires breaking all the best practices for password storage.

Question: If it is determined that the fraud-detection ability of being to retrieve passwords is necessary, what are the best practices for storing passwords securely but in a way that is plaintext-accessible?

答:
assuming the "same password" is a good way to check for fraud, and considering that giving a way to revert the stored password into the plaintext is just a very bad idea, here's how I would allow for duplicate detection :
I would still go with the "per user unique salt" scheme in order to identify my users.

In addition to that, I would also have a unique salt that's used before performing another hash on the password. All the passwords would go through hashing and be stored in a DB (not in the same table as the user table), along with the number of times it's been used. This would still allow a rainbow attack on this specific table, but you wouldn't have the user<->password link.

In other word, your attacker would be reduced to use a bruteforce dictionary attack (which he would perform anyway, and which would probably give him access to a large number of your accounts). If your user base is small, nothing prevents you from putting dummy rows in that table, just to increase the size of the dictionary your attacker would have to use.

The key here is that you don't care about which user has the newly typed password. The only thing that you'll have access to is "how many users have this password", which will allow you to reject the last subscriptions (no matter what, you can't reject subscriptions before a certain number of users have used the same password).


答: Sounds like a textbook case for the Observer pattern.  Make each node an observer of its children, and have each child inform its observers whenever its value or state changes (since I assume you'll want to adjust the cost if a child is de-selected).</p>


问:
How much help should I give during technical interviews?
I'm asked to perform or sit in during many technical interviews. We ask logic questions and simple programming problems that the interviewee is expected to be able to solve on paper. (I would rather they have access to a keyboard, but that is a problem for another time.) Sometimes I sense that people do know how to approach a problem, but they are hung up by nervousness or some second-guessing of the question (they aren't intended to be trick questions).

I've never heard my boss give any help or hints. He just thanks the interviewee for the response (no matter how good or bad it is) and moves on to the next question or problem. But I know something about the rabbit hole that defeat and nerves can lead you down, and how it disables your mind, and I can't help wondering if providing a little help now and then would ultimately help us end up with more capable programmers instead of more failed interviews.

Should I provide hints and assistance for befuddled interviewees (and if so, how far should I go while still being fair to the more prepared candidates)?

答:
You have two approaches which work both for problem solving and short technical questions:

The first one is used by your boss: don't provide any help in order to test how the person behave in a stressful context. It is a perfectly valid approach, and may give some hints about the person. After all, once you hire this person, she will not be able to receive constant help from all her colleagues.

The second one is to provide hints and support. The level of support doesn't matter too much; the only thing which matters is that the more help you provide to the person, the less you have to value her success.

Personally, I believe that you should take enough time to both be sure that the person is unable to solve a problem by her own and make the person feel that she's unable to solve it without help. But then, you may provide progressive help until you tell to the person the answer itself.

Example:

‒ Can you tell me how do you create read only properties in C#, i.e. properties with a value which can be initialized only within a constructor and cannot be changed later?

  ‒ Of course. I just use the keyword readonly.

  ‒ Are you sure? Can you explain me the difference between a property and a field?

  ‒ Hm. A property is... you see... get and set...

  ‒ Ok. So a field is a variable declared inside a class or a struct and valid within the class/struct scope, while a property is like a field, but also provides a mechanism to read, write or compute a value. Now what about readonly? Is it used with properties?

  ‒ I believe that it's used only for fields...

  ‒ Right. So what about the properties?

  ‒ They cannot be read only.

  ‒ Are you sure? What about the properties which have only getters?

  ‒ They are read only.

  ‒ Does it mean that their value will always remain the same?

  ‒ Yes.

  ‒ No, not really. The fact that you have a property with a getter doesn't mean that its value doesn't change during the lifespan of the instance of the class. If the getter refers to a field which is incremented each time you access the property, the returned value will continuously increase.

  ‒ Right.

  ‒ So? Do you have an idea of a way you can implement a property with a value which never changes?

  ‒ No.

  ‒ Well, you can use a readonly backing field. Do you know what is a backing field?

  [...]

Giving the answer is a good idea in all cases. There were several cases when the interviewee commented my answer in an interesting way, showing that even if he was unable to answer to the question in a first place, he still knows related things.

Also, by just asking a question with no further help, you are not having too much information about the person, aside the fact that she knows or doesn't know the answer. Providing progressive help may allow you to see how the person is thinking about a problem.

It may also show other things the person doesn't know. Take the example above: if I would stop at the first reply, I wouldn't have known that the person cannot explain the difference between a field and a property or that she doesn't know what a backing field is.

If the person answers immediately, it's fine. If she needs some assistance, there is nothing wrong with this. If you end up answering the question yourself, it's a bad sign and hopefully the interviewee will be able to answer the other ones.


问:
Tips on persuading boss that code review is a good thing
Let's say one works in a hypothetical company that has several developers that rarely worked together on projects and the Boss didn't believe that code reviews are worth the time and cost.

What are various arguments that could be presented in this scenario that will portray the benefit of code review?  Furthermore, what are the potential arguments against code review here and how can these be countered?

答:
Code Reviews Can:

Lead to the development of a code library that can be shared

Provide a uniform naming convention for variables, constantants, database tables

Help streamline processes

Can also lead to a review of the discover process and requirements gathering

Lead to the development of widgets we can sell as addons to applications. (Build it once get paid each time we implement it)

Lead to new products

Cons

We don't have time for that

If that's true then how come we always seem to have time to do things two or three times for the same customer but we never have enough time to do it right the first time.


答:
When I was in a similar position, I would say to the interviewee: "Pretend I'm Google. If you need to search for something just say so."

In one question interviewees needed to be able to figure out the volume of a cylinder, so I didn't mind if someone said, "I'd have to Google for the formula for the volume of a cylinder." I was interested in knowing if they knew how to attack the problem, not if they'd memorized formulas. For the job, they had to have a decent grasp of how to translate the real world into software, so it was an important concept.

On the other hand I wasn't going to tell them they needed that formula.

You are correct that nerves can be a problem, but I still expect people to be able to express their thought process, even if they're nervous. Simply not giving an answer was unacceptable.

Title: How much help should I give during technical interviews?

Body:
I'm asked to perform or sit in during many technical interviews. We ask logic questions and simple programming problems that the interviewee is expected to be able to solve on paper. (I would rather they have access to a keyboard, but that is a problem for another time.) Sometimes I sense that people do know how to approach a problem, but they are hung up by nervousness or some second-guessing of the question (they aren't intended to be trick questions).

I've never heard my boss give any help or hints. He just thanks the interviewee for the response (no matter how good or bad it is) and moves on to the next question or problem. But I know something about the rabbit hole that defeat and nerves can lead you down, and how it disables your mind, and I can't help wondering if providing a little help now and then would ultimately help us end up with more capable programmers instead of more failed interviews.

Should I provide hints and assistance for befuddled interviewees (and if so, how far should I go while still being fair to the more prepared candidates)?


答: I always like to help interviewees if they're stuck on some simple thing (like the name of a particular pattern if they obviously know what it is), and letting them gloss over things like the details of establishing a database connection.  If they're trying to design something, though, I don't say much because I don't want to either guide them or throw them off if they're thinking about something other than where I'm guessing they're going.</p>


答:
Sometimes providing minor hints during the oral interview helps to see how well candidate understands the topic(s). However, there should be no hints on standard tests that each candidate is requested to take.

Basically, there are two main things that you may want to know about potential candidate:

a) Personal characteristics - does he fit well into your company or team

b) Technical skills - does he have good technical background and interest in picking up new things

In order to learn about these mentioned points you have to engage the potential candidate into a conversation. It is also important to make sure that candidate is comfortable during the interview in order to get maximum understanding of his current skills (both soft and tech) as well as his potential to do the work.

In addition, communication skills of potential candidate are as important as his technical skills and competence to solve the problems.


答:
In computer graphics, this kind of function is called smoothstep.  When used to crossfade, it determines the global alpha value for the composition.

If the input images have an alpha channel, you should first make sure that the alpha is premultiplied.  Then, you can do the crossfade composition straightforwardly, using the smoothstep alpha on each channel [X = A*alpha + B*(1-alpha)], and expect reasonable results.

Title: The perfect crossfade

Body:
I find it hard to describe this problem in words, which is why I made a video (45 seconds) to illustrate it. Here's a preview of the questions, please have a look at it on Vimeo: http://vimeo.com/epologee/perfect-crossfade

The issue of creating a flawless crossfade or dissolve of two images or shapes has been recurring to me in a number of fields over the last decade. First in video editing, then in Flash animation and now in iOS programming. When you start googling it, there are many workarounds to be found, but I really want to solve this without a hack this time.

The summary:

What is the name of the technique or curve to apply in crossfading two semi-transparent, same-colored bitmaps, if you want the resulting transparency to match the original of either one?

Is there a (mathematical) function to calculate the neccessary partial transparency/alpha values during the fade?

Are there programming languages that have these functions as a preset, similar to the ease in, ease out or ease in out functions found in ActionScript or Cocoa?

Update: In addition to the video, I've made a sample project (requires Xcode and iOS SDK) and posted it on github. It shows the same animation as the video but this time with squares: https://github.com/epologee/StackOverflow-Example-Code


答:
Given that programmers (most of us at least) don't work in a vacuum, and that interviews are stressful enough without artificial limits, I'd be inclined to offer as much help as an interviewee asks for or needs.

But take it all into account when making a final judgement about an applicant's actual competence level.

Someone who is looking for a senior position but needs lots of help would ring alarm bells.


答: I was recently in a similar situation. The direction I got from my manager and HR was that we needed to be completely fair to all 6 interviewees, so I had to ask the same set of technical questions with minimal help to see how each interviewee performs. Sometimes when they knew the answer but stuck with a technical term or something I helped them indirectly with some questions that guided them to that term. There was a second round of interview after the technical round on personality and behavioural traits if they managed to go through the first round.</p>


答:
I agree with AndyBursh. It seems some lack of knowledge issue.

However it's important to mention frameworks like NHibernate which require you just to code in constructor (when creating map classes). However this is not a limitation of the framework, it's just what you need.
When it comes to reflection, the constructor it's the only method which will always exist (although it might be private) and this might be helpful if you have to call a method of a class dynamically.


问:
MVVM, DDD, and WPF Layered Application Project Structure Guidance
I am trying to setup my application's structure in VS and I want to "try" and future proof it to a reasonable level.  This application will be a WPF re-write of an old Winform app that had followed no conventions.  No Layers, Tiers, Acronyms, etc...

It is a fairly largish Enterprise Application.  I planned to use Linq To SQL as my DB's are and will most likely always be MS SQL.  Also I have an existing skill set with it.

I want to follow MVVM and DDD the best I can but I get confused on the structure of my application when combining these.  Let me try and illustrate with some examples.

When I follow MVVM my folder structure may look like this:

```<code>Views
Models
ViewModels
Helpers
</code>```

but how does that fit into a simplistic DDD layered approach where my Project Structure might resemble this:

```<code>MyApp.UI
MyApp.Domain
MyApp.Data
</code>```

Do I put the Models in the Domain layer or do I have 3 versions of say Person?  This leads to another question of where would I put my Repository and mappings of DB Object to Domain Object?  I would assume Data...

Views I get would go in UI but would ViewModels also?

Finally, where would I be embedding my Business Logic?

I found the following on CodePlex,DDD Example ,and it has been some help but seems to be for a Web App though that may not matter and is my ignorance shining through.

Don't get me wrong, I know I can have as many folders and call them whatever I want.  I am trying to figure out where to place things so that this will be scale-able, not what those places necessarily are called.

The heart of my question might be shown like this.

I have tblPerson object generated by *.dbml.  This is obvious and would belong in my "Data" layer.

Now I would have Model, DTO, Domain Model, or whatever it's called in a seperate Layer(project?) called Person.  I would need a Mapper for Person to tblPerson that I'm not sure where to put.

Then, I'll have a ViewModel for, say, EditPerson that would have it's own properties that it pulls from Person but possibly more as well.

Finally I'd have a View that was bound to that ViewModel....

To be clear that paragraph is FILLED with my assumptions and guesses and I am hoping someone will help clear the air for me or offer there insights so that 6 months to a year from now I am not kicking myself more than I need to.

答:
MVVM is a UI pattern and is used in a client.

The parts of the domain in DDD that are used in the client are probably (a part of) the Model

The View and ViewModel are client only.

I put Repositories in (or near) the Model because they synchronize the Model to the back-end.

Yes, many times this will result in multiple Person classes in different namespaces. They might start out very similar but might end up very different after a couple of iteration or releases.

EDIT

To clarify the part about Repositories and to explain more about the positioning of Business Logic

If you are creating a system that contains a separate client and server-side/back-end Repositories can be used in the client and the server. In the client to provide an abstraction of the server(s) and in the server to provide an abstraction of other servers and data sources. It is just a pattern.

As for Business rules: if you use those in the client make sure you enforce them in the server as well. Never trust a client. Business rules in the client allow for speedy input validation and prevent round-trips to the server.

I do think that DDD belongs on the server side and 'leaks' to the client.

OwnerDisplayName: Refracted Paladin

OwnerDisplayName: Erno


问:
How many types of programming languages are there?
Basically, I want to learn lots of programming languages to become a great programmer.  I know only a handful to depth and I was hoping someone could elaborate on how many classes or types of programming languages there are.  Like how you would lump them together if you had to learn them in groups.

Coming from a Java background, I'm familiar with static typing, but I know that in addition to dynamic typing there has to be such variety in available languages that I would love to see a categorical breakdown if possible.

答:
I tend to think in terms of features:

Syntax:

C-Based or what-have-you. Java has a C-based syntax. I highly recommend trying out something like Python or Ruby to get your head out of the syntax and thinking more in terms of fundamentals of how a given language works. I'm of the opinion that no syntax needs to get bulkier than C-based and have no problem building blocks around white-space.

Compiled vs. interpreted w. Build-Process vs. Interpreted/Console:

I have very little familiarity with compile time vs. run-time environment concerns but I get that there's a whole bag of concerns there that I rarely think about.

Likewise there are plenty of interpreted languages that still have something of a compile-ish process for running inside a virtual machine like Java does. You still have to rebuild to see changes to things.

And then there's JavaScript and Python which you can execute on the fly, command by command in a console in a live environment. All three can lead to very different ways of writing code.

Dynamic vs. Strict typing:

I tend to see the two as design tradeoffs. When you are at a much lower level and performance is critical, static typing makes a lot of sense. I've never understood this notion of one being "safer" than another somehow but I came up in a very plastic/dynamic language where you just learn how the typing system works and what to expect, basically. Type shenanigans are rarely a concern for me in JS. In some ways the flexibility can make things more robust, although admittedly a touch more arcane for a more Jr. level dev if you don't know about some of the pot-holes in the language.

Block-Level Scope vs. Function Scope vs. ?:

Block-Level is the most common (anything between {} in most c-based syntax languages). JavaScript scope is built around functions (which are also used to build objects so effectively objects too). There's also a great deal variation in what kind of access you have from inner scope to an outer-scope. I'm not familiar with other scoping schemes but I'm sure they exist.

Classical OOP vs. Prototypal OOP vs Almost-OOP(structs in C?) vs Non-OOP:

Even in class-based OOP there is a great deal of room for variation. Whether you can do multiple inheritance (ew, well in excess, ew), define interfaces, etc...

In JavaScript we have a sort of stunted hybrid prototypal OOP where objects are considerably more simple, highly mutable, but we still have the ability to separate interface from internal concerns, which IMO, is the important aspect of encapsulation.

The thing about OOP is that there really is a lot of stuff you can pull off that is essentially OOP-oriented without technically being OOP. There are purists of course but at the end of the day, Design Patterns are about achieving certain abstractions that work well in certain situations. Don't be too quick to assume ideas from an OOP-based language have no use in something that's more procedurally-oriented. And I'm not talking about JavaScript. It's not at all limited by its goofy version of a prototype based OOP paradigm.

First-Class Functions:

Not having these in a language is a hard thing for me to give up. You can pass functions around like they were data for use in other contexts. This makes event handling schemes in particular very easy to implement but it also makes it very easy to adapt the language to work the way you'd like it to. It is, more than anything I suspect, the thing that has made JavaScript the success that it ultimate has been in spite of being designed in two weeks and getting Java-approximate syntax slapped on to it as a marketing scheme.

Closures:

I'm not sure where the debate is at for Java, but I know a lot of Java devs were clamoring for this feature a year or two ago. In a non-closure language, when a function closes, anything that is somehow able to reference stuff from inside that function won't be able to access it because it was garbage collected. In a closure, execution context is bound such that if you're able to reference stuff inside that closed function from another scope like in a returned object or function you basically get those vars as they were when the function closed. It's like a jamming your foot in the door of garbage collection, although I suspect it's implemented more like copies of those vars made into local vars of the referring entity.

Rigid/Strict/Safe vs. Giving You all The Rope You Want:

JS devs and Java devs tend to not understand each other at all and I think it has a lot to do with the two languages falling on near-opposite sides of this particular design spectrum. I don't want you to protect me from myself or from the other devs on my team. I want to do a lot more in a lot less code and to do it all in very different (but consistent for a given domain) ways depending on the situation. There are absolutely tradeoffs to both and a lot of languages tend to fall more in the middle.


问:
Am I right about the differences between Floyd-Warshall, Dijkstra's and Bellman-Ford algorithms?
I've been studying the three and I'm stating my inferences from them below. Could someone tell me if I have understood them accurately enough or not? Thank you.

Dijkstra's algorithm is used only when you have a single source and you want to know the smallest path from one node to another, but fails in cases like this

Floyd-Warshall's algorithm is used when any of all the nodes can be a source, so you want the shortest distance to reach any destination node from any source node. This only fails when there are negative cycles

(this is the most important one. I mean, this is the one I'm least sure about:)

3.Bellman-Ford is used like Dijkstra's, when there is only one source. This can handle negative weights and its working is the same as Floyd-Warshall's except for one source, right?

If you need to have a look, the corresponding algorithms are (courtesy Wikipedia):

Bellman-Ford:

```<code> procedure BellmanFord(list vertices, list edges, vertex source)
   // This implementation takes in a graph, represented as lists of vertices
   // and edges, and modifies the vertices so that their distance and
   // predecessor attributes store the shortest paths.

   // Step 1: initialize graph
   for each vertex v in vertices:
       if v is source then v.distance := 0
       else v.distance := infinity
       v.predecessor := null

   // Step 2: relax edges repeatedly
   for i from 1 to size(vertices)-1:
       for each edge uv in edges: // uv is the edge from u to v
           u := uv.source
           v := uv.destination
           if u.distance + uv.weight < v.distance:
               v.distance := u.distance + uv.weight
               v.predecessor := u

   // Step 3: check for negative-weight cycles
   for each edge uv in edges:
       u := uv.source
       v := uv.destination
       if u.distance + uv.weight < v.distance:
           error "Graph contains a negative-weight cycle"
</code>```

Dijkstra:

```<code> 1  function Dijkstra(Graph, source):
 2      for each vertex v in Graph:                                // Initializations
 3          dist[v] := infinity ;                                  // Unknown distance function from
 4                                                                 // source to v
 5          previous[v] := undefined ;                             // Previous node in optimal path
 6                                                                 // from source
 7
 8      dist[source] := 0 ;                                        // Distance from source to source
 9      Q := the set of all nodes in Graph ;                       // All nodes in the graph are
10                                                                 // unoptimized - thus are in Q
11      while Q is not empty:                                      // The main loop
12          u := vertex in Q with smallest distance in dist[] ;    // Start node in first case
13          if dist[u] = infinity:
14              break ;                                            // all remaining vertices are
15                                                                 // inaccessible from source
16
17          remove u from Q ;
18          for each neighbor v of u:                              // where v has not yet been
19                                                                                removed from Q.
20              alt := dist[u] + dist_between(u, v) ;
21              if alt < dist[v]:                                  // Relax (u,v,a)
22                  dist[v] := alt ;
23                  previous[v] := u ;
24                  decrease-key v in Q;                           // Reorder v in the Queue
25      return dist;
</code>```

Floyd-Warshall:

```<code> 1 /* Assume a function edgeCost(i,j) which returns the cost of the edge from i to j
 2    (infinity if there is none).
 3    Also assume that n is the number of vertices and edgeCost(i,i) = 0
 4 */
 5
 6 int path[][];
 7 /* A 2-dimensional matrix. At each step in the algorithm, path[i][j] is the shortest path
 8    from i to j using intermediate vertices (1..k−1).  Each path[i][j] is initialized to
 9    edgeCost(i,j).
10 */
11
12 procedure FloydWarshall ()
13    for k := 1 to n
14       for i := 1 to n
15          for j := 1 to n
16             path[i][j] = min ( path[i][j], path[i][k]+path[k][j] );
</code>```

答:
If I understand you correctly, your understanding is correct.

Djikstra's finds the smallest cost path from a source node to every other node in the graph, except if there is a negative weight edge. (Dijkstra's can be transformed easily into the A* algorithm by just changing it to stop once its found the target node and adding heuristics.)

Bellman-Ford does the same as Dijkstra's, but is slower. But it can handle negative weight edges.

Floyd-Warshall finds the cost of the smallest cost path from each node to every other node. (It returns a numeric matrix.) It is far slower than either Djikstra's or Bellman-Ford. Unlike what you wrote, it does not fail when a negative cycle occurs, it just reports a meaningless negative number for the cost of some node to itself.


问:
What standard superseded 830-1998?
I have been looking into how to document software projects more formally, and I have learned about IEEE 830-1998:  Recommended Practice for Software Requirements Specifications.  However, as you can see from that link, it has been superseded.

I know that 830-1998, and probably even 830-1993, are probably just fine for use. However, if nothing else, I would like to know what standard has superseded it. In this case it may not matter, but if other standards are superseded for more technical things, I think it would be a good idea to link somewhere what standard superseded another (if it is not another one in the same line (830, in this case)).

It is worth mentioning that:

The most recent standard when searching for "Software Requirements Specifications" or "Software Requirements" on the IEEE Standards Association website is 830-1993,

The 2004 (current) version of SWEBOK references 830-1993 (paragraph 2.5),

The document's Wikipedia article doesn't mention that the standard was superseded.

TLDR:  How do you find what standard superseded another, and which one took 830-1998's place?

答:
Short answer:
830-1998 is not a standard, it is a recommended best practice on how to write SRS in the style of 1998.

I can't find how it was superseeded (even with IEEE's advanced search :( )

But I guess it's because the whole method on how we specify requirements has changed drastically in recent years.

So, from now on, I try to answer a bit of modified question:

What is the industrial best practice / What are the recommended best practices on writing SRSs in the style of 2012?

On classical methods:

Usually I use IEEE 1471 recommendations for software documentation, although that was also superseeded recently by ISO/IEC 42010. This is a very complex kind of documentation, it's mainly used for handovers, although it does contain the requirements mostly (it's chapter 7 in the new ISO style document)

A moderately good book on formal documentation is Documenting Software Architectures, a surprisingly good book is the old iconix book, and an old classic is Cockburn's Writing Effective Use Cases.

On how it is actually done in the industry today:

Truth to be told, formal project documentation, especially requirements documentation was killed off mostly in the age of Agile, as the Agile Manifesto discourages formal documentation. There is no one, single, large formal specification, but instead, there are so called user stories, product backlogs and such. This is because of iterative development, only a handful of features are specified informally for each cycle of 2-4 weeks. A renowned book is User Stories Applied.

There are so-called "executable" specifications, which are formal, since they are essentially domain-specific languages (DSLs) for testing. They are no better or worse than UML's OCL, but they're more easier to grasp perhaps but also less scientific. Most of them are called BDD frameworks, and examples include FitNesse, Cucumber, Jasmine - you'll find a big bunch of these. There are also renowned books on BDD and TDD in general.

Also, specification by software engineers was superseeded by UX design, including information architecture and interaction design, so it's not done by people who can actually code nowadays, which can lead to conflict sometimes. This is a not-so-bad example on how one looks like (it's not a standard!), but you'll find a lot more inside the UX / interaction community, but there's even a whole separate stackexchange site for them. They have their own standards, recommended best practices, etc.

But what if you want to stick with the old methods, eg. for university work?

In general, try to adhere to the IEEE 830 (can't find on their webpage what was it superseeded with, although IEEE was never good with this, I guess it's because it doesn't matter anymore unfortunately), and make sure you try to record useful information (eg, I don't think that a single actor stick figure -> single bubble with a verb-subject is considered useful) from which the overall goals of the users, the overall range of users and the overall methods of usage can be reconstructed anytime.

Why do you recommend books? Why don't you show me standards instead?

Again, I guess this document was "superseeded" because today, we have a bit of chaos around requirements specification: there are many-many viewpoints on how it should be done.

There is no single authority who is able to tell you: "this is how specifications should be made". There are best practices, and I tried to provide you with a representative list of documents and directions, albeit by no means complete, and perhaps personally biased.

At the end of the day, what matters is wether the document you create is able to fulfill all the goals all the people who ever read it have with it: what people want to see, what people need to know in order to understand the requirements are pretty well described in these books, and these are best practices on their own right, albeit in much smaller communities than a single, undivided IT community what we had perhaps in 1998.

Title: What standard superseded 830-1998?