问:
Database Change Auditing - Part of or Abstracted from ORM / Application Layer?
My fellow developers and I are at a crossroads in how to go about continuing our auditing of database changes.

Most of our applications log changes via INSERT, UPDATE, and DELETE triggers.

A few of our newer applications audit at the ORM layer; specifically using Hibernate Envers.

While ORM layer auditing provides a much cleaner interface and is much more maintainable, it will not capture any manual database changes that are made.  ORM layer auditing also means that our libraries will currently require a dependency on our ORM implementation unless, specifically in our case for example, JPA plans on providing something in the near future.

Is there a common paradigm that addresses this?

答:
There's a paradigm that addresses this.  It's called "triggers".

If there are multiple people and systems that can touch the data outside the control of your code, then the code can't log those changes.  You need it in a layer close to the data so it won't be bypassed.

Is this a violation of layers? Maybe. But so are primary and foreign keys. They enforce things at a layer close to the data that could theoretically be enforced by code exclusively. Keep an open mind and don't follow a particular design method as gospel.


问:
What functionality does dynamic typing allow?
I've been using python for a few days now and I think I understand the difference between dynamic and static typing. What I don't understand is under what circumstances it would be preferred. It is flexible and readable, but at the expense of more runtime checks and additional required unit testing.

Aside from non-functional criteria like flexibility and readability, what reasons are there to choose dynamic typing? What can I do with dynamic typing that isn't possible otherwise? What specific code example can you think of that illustrates a concrete advantage of dynamic typing?

答:
There is nothing you can do with dynamic typing that you can't do with static typing, because you can implement dynamic typing on top of a statically typed language.

A short example in Haskell:

```<code>data Data = DString String | DInt Int | DDouble Double

-- defining a '+' operator here, with explicit promotion behavior
DString a + DString b = DString (a ++ b)
DString a + DInt b = DString (a ++ show b)
DString a + DDouble b = DString (a ++ show b)
DInt a + DString b = DString (show a ++ b)
DInt a + DInt b = DInt (a + b)
DInt a + DDouble b = DDouble (fromIntegral a + b)
DDouble a + DString b = DString (show a ++ b)
DDouble a + DInt b = DDouble (a + fromIntegral b)
DDouble a + DDouble b = DDouble (a + b)
</code>```

With enough cases you can implement any given dynamic type system.

Conversely, you can also translate any statically typed program into an equivalent dynamic one.  Of course, you would lose all compile-time assurances of correctness that the statically typed language provides.

Edit: I wanted to keep this simple, but here are more details about an object model

A function takes a list of Data as arguments and performs calculations with side effects in ImplMonad, and returns a Data.

```<code>type Function = [Data] -> ImplMonad Data
</code>```

DMember is either a member value or a function.

```<code>data DMember = DMemValue Data | DMemFunction Function
</code>```

Extend Data to include Objects and Functions.  Objects are lists of named members.

```<code>data Data = .... | DObject [(String, DMember)] | DFunction Function
</code>```

These static types are sufficient to implement every dynamically typed object system I'm familiar with.

ContentLicense: CC BY-SA 3.0

Body:
There is nothing you can do with dynamic typing that you can't do with static typing, because you can implement dynamic typing on top of a statically typed language.

A short example in Haskell:

data Data = DString String | DInt Int | DDouble Double

-- defining a '+' operator here, with explicit promotion behavior
DString a + DString b = DString (a ++ b)
DString a + DInt b = DString (a ++ show b)
DString a + DDouble b = DString (a ++ show b)
DInt a + DString b = DString (show a ++ b)
DInt a + DInt b = DInt (a + b)
DInt a + DDouble b = DDouble (fromIntegral a + b)
DDouble a + DString b = DString (show a ++ b)
DDouble a + DInt b = DDouble (a + fromIntegral b)
DDouble a + DDouble b = DDouble (a + b)

With enough cases you can implement any given dynamic type system.

Conversely, you can also translate any statically typed program into an equivalent dynamic one.  Of course, you would lose all compile-time assurances of correctness that the statically typed language provides.

Edit: I wanted to keep this simple, but here are more details about an object model

A function takes a list of Data as arguments and performs calculations with side effects in ImplMonad, and returns a Data.

type Function = [Data] -> ImplMonad Data

DMember is either a member value or a function.

data DMember = DMemValue Data | DMemFunction Function

Extend Data to include Objects and Functions.  Objects are lists of named members.

data Data = .... | DObject [(String, DMember)] | DFunction Function

These static types are sufficient to implement every dynamically typed object system I'm familiar with.


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

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

Any insight into this would be great

答:
I vote that you embrace design to at least some degree.  Some introductory material that I like is included in a Mix 09 talk Design for Developers by Robby Ingebretsen.  If I remember right, there is material in this talk about making a team that includes several specializations.

Many of the development tools are pushing toward templating a huge portion of the designers job, particularly the interaction designers job, on to the programmer, or at least into his tool set.

Whether your designer is your partner or a subcontractor, as a trained software developer and key stakeholder, your involvement throughout the process can insure that requirements are elicited effectively and scope is defined to produce a cost effective and rapid solution for the client.


问:
Compiling vs using pre-built binaries performance?
Will performance be better (quicker) if I manually compile the source for a software component for the actual machine that it will be used on, compared to if the source was compiled on another platform perhaps for many different architectures? I got some good results compiling source that I downloaded and I wonder whether this was due to compiling it instead of downloading a pre-compiled binary which is often the case with software updates.</p>

答:
This really depends on the two compilers and compiler flags used.  Usually, the compiler and flag settings on your local machine are more appropriate to your particular machine if you have things configured correctly.

But, if, for instance, the pre-built binary happened to be built with a much better optimizing compiler (or a benchmark special designed with flags tuned for that particular piece of code and by luck appropriate for your system) compared to the compiler on your system, then it's possible that whatever compiler is on your system might actually produce worse performance.


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

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

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

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

答:
I have seen developers who finish early because they are not thorough.  In my book, developers  have no less responsibility for testing than testers, so if testers are finding many things that need to be reported, it adds both administrative time and later on re-testing time.

Developers can build very impressive collections of unit tests to run and still the code can have spectacular failures.  Perhaps the cause is that they are considering the required functionality too narrowly.  Perhaps it may go back to the use cases which may need to call out more alternate flows.  Or perhaps it is a sign of poor code quality matched up with too few or too naive unit tests.

In some development environments, there may be many features that are tested with simulators or given a pass because they are too hard for developers to test with what they have available at their desk.  In the interest of fairness, the scope of developer test vs. acceptance test is a huge factor in how much testers must work.

Another consideration is the ratio of developers to testers and the complexity of the test configuration relative to the tools available to automate the testing.  If development runs unit tests in ten minutes, but complex user interactions or tests with hardware and external devices are not part of their testing, perhaps it is normal for the testers to be long pole.  Testers may do a lot more to document their work than developers and if this is true there might be some kind of assessment about whether one side is taking short cuts or the other is doing unnecessary work.

Developers should not influence testers in ways that compromise their objectivity.  However, I think is it very reasonable for developers to share documentation about their unit testing and the code that was changed with testers.  In some groups, developers do a bunch of work, then hand off builds to testers when the schedule is almost exhausted.  In other groups, testers get daily builds, so testing can proceed with new bits as they become available.  In some groups, testers can even generate their own builds that are timed to their best advantage.

Some teams are adding people with the title Software Development Engineer in Test so that they can have highly trained staff to do code/decision coverage testing.  This may run counter to some Agile guidelines, but so do the developer test practices that we say we should do but don't.

Title: Finishing an iteration early


问:
Processing a stream. Must layers be violated?
Theoretical situation:

One trillion foobars are stored in a text file (no fancy databases). Each foobar must have some business logic executed on it. A set of 1 trillion will not fit in memory so the data layer cannot return a big set to the business layer. Instead they are to be streamed in 1 foobar at a time, and have business logic execute on 1 foobar at a time.  The stream must be closed when finished.

In order for the stream to be closed the business layer must close the stream (a data operation detail), thus violating the separation of concerns.

Is it possible to incrementally process data without violating layers?

答:
Is it possible to incrementally process data without violating layers?

Yes, it is. You have to define unit of work which will solve your confusion. I think processing set of records (100 or 1000 depend on processing time of an average record) or a record at a time will have more reliable and manageable results.

In addition, i would make sure that data manipulation process (business processing) is in a transaction, all error processing's are recorded and rolled back for investigation. You may always have some exceptional situations which must be taken into account.


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

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

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

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

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

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

答:
Even though you're feeling raw for being "forced to work overtime", starting a fight isn't the answer right now - not until you've a better job lined up anyhow.

Indeed, it is an unfortunate situation, but there's a couple of things to check first:

a) Is there anything in your contract that states your working hours or something similar, such that your employer would actually be in breach of your contract to force you to work?

b) Is it legal in your country/state/region for your boss to make you work beyond, e.g. 48 hours per week?

Either of these items, when presented to your (project) manager, would give a clear reason why you can't do overtime - it breaks the contract/law.

If not, there's no benefit in pointing the finger of blame right now - the project needs to be completed on schedule, so I would advise to try to identify some possible solutions that your (project) manager could use to meet the deadlines. Yes, this is doing their job, but clearly (as you have stated) they are struggling to be effective at it by themselves already. Your software engineering input may give them a good insight into what they underestimated or failed to research properly.

Some workable solutions could be:

Offer to work with the PM to identify the work items on the critical path and prioritise resources accordingly to meet this.

Escalate the issue up the management chain to see if there's any resources available in other departments.

Get some contract resource - expensive, yes, but potentially highly skilled and willing to work extra if paid by the hour.

Come to some (temporary) formal arrangement with you - for example, double time-off-in-lieu, doubled hourly-rate, a new car, your PM's soul, etc.

Work with the business managers to negotiate a phased release of the software so that the schedule can be met. Rather than "100% features by deadline", pitch for "100% of critical features by deadline, rest of features shortly after" or something similar.

ContentLicense: CC BY-SA 2.5


问:
How do you stay motivated for hobby projects?
I started seriously programming as a hobbiest, student and then intern about 4 years ago and I've always done small projects on the side as a learning exercise.  Schools over now though, and I spend my days at work as a software developer. I would still love to do projects on the side to learn about areas in computer science that I'm not exposed to at work, but I've noticed that after 8 hours of starring at an IDE it's far to tempting to veg out.  Any time I do get up the gumption to work on something for a few hours lately it's gotten left by the wayside.

Anyone have any advice for sticking with side projects when you spend most of your day coding?

答:
Nice question, particularly since I'm planning on starting a hobby project myself (not the first hobby project, but projects in the past have tended to fall flat on their face when I get bored of them, which is dissatisfying to say the least).

My tips, though:

Develop something you care about.  Pretty obvious really, and been mentioned a few times, but does really deserve to be said again.  If you're developing just for the sake of it, you'll eventually get bored.

Come up with a small feature set, develop for that and then build on it.  If you're writing a word processor, don't try to include every feature in Word.  If you're working on an image manipulation package, don't try to beat PhotoShop.  If you're cooking up an IDE or some dev tools, don't... well, you get the idea.  Once you've got that simple version done, that's your first milestone - an accomplishment, something you can feel proud of.

Pick something you can develop, test, etc.  Don't go for some server app that requires you to spend £3000 on testing hardware (or lots of money on hosting).

Write it in a language you want to learn, and one that has features that will help you, but something that will provide an interesting (!important word!) challenge.

Pick a gap in the market, so to speak, and look at what your prospective competition are doing.  What aren't they doing?  Could you do it better, maybe learn from their mistakes?


答:
Define an abstract interface that presents a foobar (or whatever set of foobars is required), leaving it up to the implementation of the abstraction to determine how the foobars are acquired and/or modified.

Naturally, you need to define the elements of this interface around that actual conditions. If the only way to count the foobars is to stream past all trillion, don't include "get the number of foobars" in your interface.  But probably your interface will contain some elements like "start" "stop" and "abort" in addition to "get"

Title: Processing a stream. Must layers be violated?

Body:
Theoretical situation:

One trillion foobars are stored in a text file (no fancy databases). Each foobar must have some business logic executed on it. A set of 1 trillion will not fit in memory so the data layer cannot return a big set to the business layer. Instead they are to be streamed in 1 foobar at a time, and have business logic execute on 1 foobar at a time.  The stream must be closed when finished.

In order for the stream to be closed the business layer must close the stream (a data operation detail), thus violating the separation of concerns.

Is it possible to incrementally process data without violating layers?


问:
External file (images, sounds) naming convention at Xcode

What is better naming conventions at Xcode regardng External File
(images, sounds) etc?

Is there any guideline from vendor Apple?

As we store our projects at SVN, is there any complicity from Hosted
Server (we use Linux + Server SVN ) ?

答:
Better to follow Unix naming conventions here

Always use lowercase characters

Only 1 dot for file extension, otherwise no dot allowed

No white space allowed

For long file name use hyphen(-)

If you follow Unix naming conventions, there will no complexity as your server configuration.


答:
Phrases like "static typing" and "dynamic typing" are thrown around a lot, and people tend to use subtly different definitions, so let's start by clarifying what we mean.

Consider a language that has static types that are checked at compile-time. But say that a type error generates only a non-fatal warning, and at runtime, everything is duck-typed. These static types are only for the programmer's convenience, and do not affect the codegen. This illustrates that static typing does not by itself impose any limitations, and is not mutually exclusive with dynamic typing. (Objective-C is a lot like this.)

But most static type systems do not behave this way. There's two common properties of static type systems that can impose limitations:

The compiler may reject a program that contains a static type error.

This is a limitation because many type safe programs necessarily contain a static type error.

For example, I have a Python script that needs to run as both Python 2 and Python 3. Some functions changed their parameter types between Python 2 and 3, so I have code like this:

```<code>if sys.version_info[0] == 2:
    wfile.write(txt)
else:
    wfile.write(bytes(txt, 'utf-8'))
</code>```

A Python 2 static type checker would reject the Python 3 code (and vice versa), even though it would never be executed. My type safe program contains a static type error.

As another example, consider a Mac program that wants to run on OS X 10.6, but take advantage of new features in 10.7. The 10.7 methods may or may not exist at runtime, and it's on me, the programmer, to detect them. A static type checker is forced to either reject my program to ensure type safety, or accept the program, along with the possibility of producing a type error (function missing) at runtime.

Static type checking assumes that the runtime environment is adequately described by the compile time information. But predicting the future is perilous!

Here's one more limitation:

The compiler may generate code that assumes the runtime type is the static type.

Assuming the static types are "correct" provides many opportunities for optimization, but these optimizations can be limiting. A good example is proxy objects, e.g. remoting. Say you wish to have a local proxy object that forwards method invocations to a real object in another process. It would be nice if the proxy were generic (so it can masquerade as any object) and transparent (so that existing code does not need to know it is talking to a proxy). But to do this, the compiler cannot generate code that assumes the static types are correct, e.g. by statically inlining method calls, because that will fail if the object is actually a proxy.

Examples of such remoting in action include ObjC's NSXPCConnection or C#'s TransparentProxy (whose implementation required a few pessimizations in the runtime - see here for a discussion).

When the codegen is not dependent on the static types, and you have facilities like message forwarding, you can do lots of cool stuff with proxy objects, debugging, etc.

So that's a sampling of some of the stuff you can do if you are not required to satisfy a type checker. The limitations are not imposed by static types, but by enforced static type checking.

Title: What functionality does dynamic typing allow?

Body:
I've been using python for a few days now and I think I understand the difference between dynamic and static typing. What I don't understand is under what circumstances it would be preferred. It is flexible and readable, but at the expense of more runtime checks and additional required unit testing.

Aside from non-functional criteria like flexibility and readability, what reasons are there to choose dynamic typing? What can I do with dynamic typing that isn't possible otherwise? What specific code example can you think of that illustrates a concrete advantage of dynamic typing?

Body:
Phrases like "static typing" and "dynamic typing" are thrown around a lot, and people tend to use subtly different definitions, so let's start by clarifying what we mean.

Consider a language that has static types that are checked at compile-time. But say that a type error generates only a non-fatal warning, and at runtime, everything is duck-typed. These static types are only for the programmer's convenience, and do not affect the codegen. This illustrates that static typing does not by itself impose any limitations, and is not mutually exclusive with dynamic typing. (Objective-C is a lot like this.)

But most static type systems do not behave this way. There's two common properties of static type systems that can impose limitations:

The compiler may reject a program that contains a static type error.

This is a limitation because many type safe programs necessarily contain a static type error.

For example, I have a Python script that needs to run as both Python 2 and Python 3. Some functions changed their parameter types between Python 2 and 3, so I have code like this:

if sys.version_info[0] == 2:
    wfile.write(txt)
else:
    wfile.write(bytes(txt, 'utf-8'))

A Python 2 static type checker would reject the Python 3 code (and vice versa), even though it would never be executed. My type safe program contains a static type error.

As another example, consider a Mac program that wants to run on OS X 10.6, but take advantage of new features in 10.7. The 10.7 methods may or may not exist at runtime, and it's on me, the programmer, to detect them. A static type checker is forced to either reject my program to ensure type safety, or accept the program, along with the possibility of producing a type error (function missing) at runtime.

Static type checking assumes that the runtime environment is adequately described by the compile time information. But predicting the future is perilous!

Here's one more limitation:

The compiler may generate code that assumes the runtime type is the static type.

Assuming the static types are "correct" provides many opportunities for optimization, but these optimizations can be limiting. A good example is proxy objects, e.g. remoting. Say you wish to have a local proxy object that forwards method invocations to a real object in another process. It would be nice if the proxy were generic (so it can masquerade as any object) and transparent (so that existing code does not need to know it is talking to a proxy). But to do this, the compiler cannot generate code that assumes the static types are correct, e.g. by statically inlining method calls, because that will fail if the object is actually a proxy.

Examples of such remoting in action include ObjC's NSXPCConnection or C#'s TransparentProxy (whose implementation required a few pessimizations in the runtime - see here for a discussion).

When the codegen is not dependent on the static types, and you have facilities like message forwarding, you can do lots of cool stuff with proxy objects, debugging, etc.

So that's a sampling of some of the stuff you can do if you are not required to satisfy a type checker. The limitations are not imposed by static types, but by enforced static type checking.


答:
Good question.

Here is a C#-ish code that lets you have it both ways. The trick here is lazy evaluation (yield).

```<code>// Lazy producer that will auto-close the file.
// The OS and the disk do the caching for you.
public static IEnumerable<FooBar> GetFoobars(string fileName, long maxNumber = 1000000000000)
{
    using(File file = open(fileName)) // pseudocode
    {
        FooBar nextFooBar;
        do
        {
            nextFoobar = new Foobar(file.ReadByte()); // or something like that.
            yield return nextFoobar;
        }
        while(nextFooBar != null || /* reach max */); // pseudocode
    }
}

// Consumer ... stupid example. Oh well ...
public static int Consume()
{
    int result = (from foo in GetFoobars("foo.txt").AsParallel()
                 where foo.Depth % 10 == 0).Count();
    return result;
}
</code>```

The GetFoobars(...) function know which file to open, how many thingies to read and how to close the stream. You just pull on the results as you need them. Concerns are separated. What seems to be the problem? You could probably do the whole thing as a one-liner ... maybe not, but close.

P.S. I recommend going through SICP video lectures.

Body:
Good question.

Here is a C#-ish code that lets you have it both ways. The trick here is lazy evaluation (yield).

// Lazy producer that will auto-close the file.
// The OS and the disk do the caching for you.
public static IEnumerable<FooBar> GetFoobars(string fileName, long maxNumber = 1000000000000)
{
    using(File file = open(fileName)) // pseudocode
    {
        FooBar nextFooBar;
        do
        {
            nextFoobar = new Foobar(file.ReadByte()); // or something like that.
            yield return nextFoobar;
        }
        while(nextFooBar != null || /* reach max */); // pseudocode
    }
}

// Consumer ... stupid example. Oh well ...
public static int Consume()
{
    int result = (from foo in GetFoobars("foo.txt").AsParallel()
                 where foo.Depth % 10 == 0).Count();
    return result;
}

The GetFoobars(...) function know which file to open, how many thingies to read and how to close the stream. You just pull on the results as you need them. Concerns are separated. What seems to be the problem? You could probably do the whole thing as a one-liner ... maybe not, but close.

P.S. I recommend going through SICP video lectures.


答:
I look at this in simple terms of contract. I have a contract with my employer that states I will work X hours per week on average, get Y days of paid leave per year, may have to travel as part of my work and so on.

That's fine, I signed it and my employer signed it. That is the deal between us.

If they start to expect me to work X+5 hours per week then either we need to re-evaluate that contract or I have every right to just refuse. If my employer were to fire me for sticking to the letter of my contract I would have enough legal recourse to make life very difficult and expensive with them.

That doesn't mean I won't put in extra time if it's needed - I'm very happy to - but if the need was relentless, I would want to see some recompense for that or to substitute leave for it. And I would reserve the right to refuse because I have other things that are more important to me than my day job.

If you are paid for a 10 hour day and you work a 12 hour day, what you are telling your employer is that your work is worth 20% less than your contracted rate. You are essentially accepting a pay cut and your employers are treating you as a free resource to exploit as hard as they can.

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

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

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

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

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

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

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


问:
How to justify rewriting/revamping legacy software in a business case?
I work for a great little software company which makes good revenue from our main software package.  The problem for me is that it's almost unmaintainable.  It's written in Delphi 7 (has upgraded versions over time) and has been worked on by a lot of developers over the past 20 or so years.

The software lacks any meaningful architecture - there's no object orientation whatsoever, horrible amounts of cyclical dependencies and an over-reliance on global variables to name just a few things.  Another huge thing for me is Delphi 7 does NOT support 64-bit.

The problem here for me is that my management team don't care about technical things, they want to know why they should care.  Obviously that's expected, so what I'm asking here is for some guidance, or tales, or pitfalls about this kind of thing.

There's a few things I would love to include, namely for me, the length of time taken to debug/write a feature in "legacy" code, versus coherent, well structured OO code.  Does anyone know of any blog posts or the like where this is talked about?  For us in the company this is a huge reason.  Despite being decent developers we feel like writing a new feature is just piling more rubbish on top.  On top of that, even for me who has a decent level of understanding of the code, changing things is infuriating - a small change can have a ridiculous domino effect.

Anyone have any experiences they'd like to share?

答:
Read Joel on Software - Things You Should Never Do, Part I, or hope you managers don't. Mine obviously had not read it, I bet now, if they have, they wish they had earlier.....

I work on a project rewritten in Java from over a million lines of legacy ADA codebase. We now have less than a million lines of new "Java syntax" legacy Ada program, with a whole raft of defects that did not exist before, and a number of new features that sort of work most of the time. Fortunately we also have a Unit testing framework so when a defect get found we can write yet another unit test that fails, fix the defect, watch that unit pass and a dozen others fail......

Essentially only a fool would chuck out working code for the empty promises of a new code base.


答:
Membranes:

A membrane is a wrapper around an entire object graph, as opposed to a wrapper for just a single object. Typically, the creator of a membrane starts out wrapping just a single object in a membrane. The key idea is that any object reference that crosses the membrane is itself transitively wrapped in the same membrane.

Each type is wrapped by a type that has the same interface, but which intercepts messages and wraps and unwraps values as they cross the membrane.  What is the type of the wrap function in your favorite statically typed language?  Maybe Haskell has a type for that functions, but most statically typed languages don't or they end up using Object → Object, effectively abdicating their responsibility as type-checkers.


问:
In a team practicing Domain Driven Design, should the whole team participate in Stakeholder meetings?
In my experience, a Software Development Team that comprises:

1  Project Manager

1  Tech Lead

1 - 2 Senior Dev

2 - 3 Junior Dev (Fresh grad)

Only the Tech Lead & PM (and/or Senor Dev/s) will participate in a meeting with Clients, Domain Experts, Client's technical resource.

I can think of the ff potential pitfalls:

Important info gets lost

Human error (TL/PM might forgot to disseminate info due to pressure or plain human error)

Non-verbal info (maybe a presentation using a diagram presented by Domain Expert)

Maintaining Ubiquitous language is harder to build since not all team members get to hear the non-dev persons

Potential of creative minds are not fully realized (Personally, I am more motivated to think/explore when I am involved with these important meetings)

Advantages of this approach:

Only one point of contact

Less time spent on meetings?

Honestly, I am biased & against this approach. I would like to hear your opinions. Is this how you do it in your team?

答:
There is one problem with composition of your team: Domain experts are not part of the team.

One of the key points of DDD is to include Domain Experts in team to ensure better collaboration and emergence of ubiquitous language. Of course, they don't need to work full-time for team, there probably wont be enough work for them here. But, they need to be available at any time for developers to ask questions and clarifications. This approach has all the advantages and none of the disadvantages.

Only problem is how to get client to "lend" you the domain experts while they are not really your employees. But I'm sure there are some HR ways to make this easy and simple.


答:
How do you make a business case for spending a ton of money writing piece of software that does exactly the same thing as the software you have now, plus, the additional risk that it will not do exactly the same thing?

Good Luck.

Title: How to justify rewriting/revamping legacy software in a business case?

Body:
I work for a great little software company which makes good revenue from our main software package.  The problem for me is that it's almost unmaintainable.  It's written in Delphi 7 (has upgraded versions over time) and has been worked on by a lot of developers over the past 20 or so years.

The software lacks any meaningful architecture - there's no object orientation whatsoever, horrible amounts of cyclical dependencies and an over-reliance on global variables to name just a few things.  Another huge thing for me is Delphi 7 does NOT support 64-bit.

The problem here for me is that my management team don't care about technical things, they want to know why they should care.  Obviously that's expected, so what I'm asking here is for some guidance, or tales, or pitfalls about this kind of thing.

There's a few things I would love to include, namely for me, the length of time taken to debug/write a feature in "legacy" code, versus coherent, well structured OO code.  Does anyone know of any blog posts or the like where this is talked about?  For us in the company this is a huge reason.  Despite being decent developers we feel like writing a new feature is just piling more rubbish on top.  On top of that, even for me who has a decent level of understanding of the code, changing things is infuriating - a small change can have a ridiculous domino effect.

Anyone have any experiences they'd like to share?


答:
Several years ago I have worked in a place where it was usual to put whole teams into meetings, just for the sake not to exclude anyone. Now, for almost ten years I work in a place where only those persons meet who really need to discuss things together, and other team members are only invited occasionally (and not for the whole meeting) to discussions about topics which are directly related to their work.

From that experience, I can tell you that the second approach is much more efficient. However, it works so well because everyone can ask questions to our domain experts whenever a question arises, independently of any formal meeting.

I also recomend to have a look into Steve Maguire's book "Debugging the Development Process". He describes that one important step in improving the efficiency of a development team is to keep them away from unneccessary distractions like needless meetings. From my own experience, I can confirm this 100%

Title: In a team practicing Domain Driven Design, should the whole team participate in Stakeholder meetings?

Body:
In my experience, a Software Development Team that comprises:

1  Project Manager

1  Tech Lead

1 - 2 Senior Dev

2 - 3 Junior Dev (Fresh grad)

Only the Tech Lead & PM (and/or Senor Dev/s) will participate in a meeting with Clients, Domain Experts, Client's technical resource.

I can think of the ff potential pitfalls:

Important info gets lost

Human error (TL/PM might forgot to disseminate info due to pressure or plain human error)

Non-verbal info (maybe a presentation using a diagram presented by Domain Expert)

Maintaining Ubiquitous language is harder to build since not all team members get to hear the non-dev persons

Potential of creative minds are not fully realized (Personally, I am more motivated to think/explore when I am involved with these important meetings)

Advantages of this approach:

Only one point of contact

Less time spent on meetings?

Honestly, I am biased & against this approach. I would like to hear your opinions. Is this how you do it in your team?


问:
Unit testing a text index
Consider a text index such as a suffix tree or a suffix array supporting Count queries (number of occurrences of a pattern) and Locate queries (the positions of all the occurrences of a pattern) over a given text. How would you go about unit testing such a class ?

What I have in mind is to generate a big random string then extract a random substring from this big string and compare the results of both queries with naive implementations (such as string::find). Another idea I have is to find the most frequent substring of length l appearing in the original string (using perhaps a naive method) and use these substrings for testing the index.

This isn't the best way, so what would be a good design of the unit tests for a text index ?

In case it matters, this is in C++ using google test.

答:
The random generated big string can be a nice addition to test the cases that you did not think of. To make it effective you would need to run it several times which slows down your unit testing suite, so you need to find a balance between the number of times you run the test and how big you would make the string.

I would still create a normal test set with a given input for which you know what the answer is.

a test for zero occurrences

a test for a random number of occurrences

a test for an occurrence in the first element

a test for an occurrence in the last element

a test for case sensitive

a test with an empty tree or array

a test for a tree or array with exactly one element

tests for any other functional requirements you might have (escape characters, line endings, ignoring white space, concurrent use, exception handling,  more occurrences than your counter can hold)

Hope this helps.

Title: Unit testing a text index


答: It'll be good to have a group for a project... find some fellow programmers with same interest as yours... It feels tempting when your fella has done some advancement in that project and you haven't. This is surely motivating.</p>

Title: How do you stay motivated for hobby projects?

Body:
I started seriously programming as a hobbiest, student and then intern about 4 years ago and I've always done small projects on the side as a learning exercise.  Schools over now though, and I spend my days at work as a software developer. I would still love to do projects on the side to learn about areas in computer science that I'm not exposed to at work, but I've noticed that after 8 hours of starring at an IDE it's far to tempting to veg out.  Any time I do get up the gumption to work on something for a few hours lately it's gotten left by the wayside.

Anyone have any advice for sticking with side projects when you spend most of your day coding?


问:
Preparing yourself for сode challenges
Just a few days ago I discovered Codility, and I tried their challenges. And I must say. I got my behind handed to me on a platter. I'm not sure what the problem was, but I'll lick my wounds and wait for the solution to come out and compare it with my own. In the meantime, I want to get ready for the next challenge so I'm reading their previous blog posts and seeing how to solve their previous problems. There are a lot of new things I haven't heard about like (Cartesian trees, various sort algorithms, etc.)

So, how does one prepare for such challenges (especially the O(x) time and space complexity). What should I read to prepare for such a task?

答:
The only thing that you can do to prepare yourself for such kind of tests is practice. Practice a lot. There are a lot of good resouces for coders help, such as topcoder, codegolf, geeks for geeks, Programming Praxies, CodeKata, Project Euler etc.

If you are having problems with data structures, it would be better that you brush up your algorithm and data structure concepts. Best Place for that is wikipedia, but you can also look for algo data courses on nptel, coursera, etc...

Title: Preparing yourself for сode challenges


问:
Should a domain expert make class diagrams?
The domain expert in our team uses UML class diagrams to model the domain model.

As a result, the class diagrams are more of technical models rather than domain models (it serves of some sort of technical specifications for developpers because they don't have to do any conception, they just have to implement the model).

In the end, the domain expert ends up doing the job of the architect/technical expert right?

Is it normal for a domain expert (not a developer or technical profile) to do class diagrams?

If not, what kind of modeling should he be using?

答:
There are a couple of things in your description of the scenario that don't smell right to me.

Class diagrams are capturing only a portion of the domain complexity. They focus on the static structure and ignore behavioral aspects. I bet the class diagram looks a lot like a data model too. UML is not intrinsically bad, but focusing on class diagram only ...it is.

"they just have to implement the model" ... :-( what sounds terribly wrong here is that you're probably missing the conversation around the domain model. Domain-Driven Design implies a process of deep shared understanding of the domain, and the situation you're describing is allowing developers to code without understanding the domain.

What kind of modeling should he be using?
The process of creating a model should be collaborative, meaning that there should be a conversation and 2-4 persons drawing models on a whiteboard, or sketching them on a piece of paper, or writing user stories, or quickly coding tests (normally in a quick feedback loop). This way, modeling is not a single person's duty. As a consequence, the modeling technique used should be the one that allows better dialogue, meaning shared understanding and maximum amount of feedback from the Domain Expert.

I personally had good experiences focusing domain explorations on flow of Domain Events rather than the static structure of the classes. Models tend to be completely behavioral, allowing for a quicker understanding of the whole picture.


答:
UML models (and ERD models) have types. The conceptual type (logical type) and the physical type. The physical type is what gets tuned and implemented. The physical model is driven from conceptual model. UML offers the modeler to specify great details in a concise way and is good for both types of models.

If the modeler knows what they are doing, the produced model could represent a correct specification. Whether that specification is qualified to be a physical model or not, well, this is a different story and depends on several factors.

When crafting a logical model, the purity of captured requirements may be accidentally sacrificed. The modeler may produce a non-pure logical model when he/she documents user requirements in the logical model, for example, when he/she resolves an m-m relationship. While valid, the original requirement is now lost unless the new resulting class is well documented. There are many similar situations that could result in specifications that are not traceable such as assuming Primary Keys. The other thing is that users, in general, may not be a able to review the UML diagram. So the UML diagram can't replace user requirements specification documentation. This results in more work being done.

To summarize, you can have logical models capture the requirements but you should:

Have an agreed standard of documenting user requirements within the project.

Clearly identify roles and responsibilities in the project.

Differentiate requirements gathering deliverable from Physical design.

Ensure user requirements are traceable and that users can verify what they told the business analyst.

Title: Should a domain expert make class diagrams?

Body:
The domain expert in our team uses UML class diagrams to model the domain model.

As a result, the class diagrams are more of technical models rather than domain models (it serves of some sort of technical specifications for developpers because they don't have to do any conception, they just have to implement the model).

In the end, the domain expert ends up doing the job of the architect/technical expert right?

Is it normal for a domain expert (not a developer or technical profile) to do class diagrams?

If not, what kind of modeling should he be using?


答:
Let responsibility and authority be your guide.  If someone has responsibility or authority to make decisions, and the subject of those decisions is discussed, they should probably be at the meeting.

However, Fred Brooks talks about the Design of Design and compares and contrasts several things that were made by committee with things that were made by great software visionaries.


答:
I don't think it's about the role, but it's a lot about the attitude. In a perfect scenario I would try to have all the relevant person in the same room to actively discuss about the model. But in a perfect scenario I beed to have a suitable available room, with the required tools and people disciplined enough to manage this conversation. It isn't that easy.

For creative collaboration to effectively happen, a weird non-technical thing called alchemy is probably requirement number one. The Domain Expert is the most important source of information (though not the only one) and he should be at ease with exploring the model together with the team, or part of it. If meetings are too long, too boring or meaningless, attention is lost, and we've missed our goal. Also, some developers might not have the right attitude to participate in this meeting. A facilitator role, to prevent conversation from becoming too technical, might be useful.

The whole goal is a deep shared understanding of the domain. This won't happen if there is a layer between the DE and the team. But if the meeting is unpleasant, it won't happen either. So my rule of thumb is "bring people willing to participate, unless this is making the meeting meaningless". According to the starting point this might be a process of gradual insertion of more people, starting from the ones that want to participate.

Also, the right type of Domain Expert (the one that knows the answers to the why questions) might not be so easily available. So having a big meeting when everybody is present is probably less efficient than having a smaller meeting sooner.


问:
Good Practices of writing release notes
At the delivery of every version of software we have to write a release note.
For example, here are some of the terms I add when I write a release note:

Release Date

Bug Solved

Is that enough, or is there anything else?

答:
I think followings will give a way to good practices

// Date Related

Release Date

// Feature related

Features Added

Featured Removed

Features Changed

// Bug related

Solved Bugs

Unsolved Bugs

// Dependency related

List of dependency

// Testing related

Unit Test results

Acceptance Test results

// Version controlling related

Tag Note

Revision Number

Also some times worth highlighting things the end user may want to change in their configurations or workflow.

Most end users don't care about the test result. They expect it to have high quality no matter what the release note says.

The most important thing about release notes is to be aware that every
  additional sentence loses another 10% of the readers. So you must
  strictly prioritize what your current users need to know about the
  release.

Title: Good Practices of writing release notes

ContentLicense: CC BY-SA 4.0


问:
Project Management Techniques (high level)
Our software dev team is currently using kanban for our development lifecycles, and, from the reasonably short experience of a few months, I think it's going quite well (certainly compared to a few months ago when we didn't really have a methodology).

Our team, however, is directed to do work defined by project managers (not software project managers, just general business), and they're using the PMBOK methodology.

Question is, how does a traditional methodology like PMBOK, Prince2 etc fit with a lean software development methodology like kanban or scrum? Is it just wasting everyone's time as all the requirements are effectively drawn up to start with (although inevitably changed along the way)?

答:
I'm not a massive expert in this area. But I think that you can try two things here:

1 Use a Kanban board to visualise the PMBOK/Prince2 process that's being used.  Simply show the Project Managers this 'visualisation aid', for me that's what Kanban is for - showing you where you have bottlenecks and blockers. Assuming you get the usual waterfall style problems, you'll be able to show this on your Kanban board as the workflow gets slowed or blocked at various points.  You can then use this as a starting point to get them to come around to agreeing to letting you run the project in a more agile manner.

And/Or

2 Take the requirements and split it into a Kanban style project anyhow, but do some analysis/preparation up front on how you can report progress back to the Project Managers in a Prince2/PMBOK manner (that will be comfortable to them).  You might find that the PM's don't care how you run the project, as long as the reporting meets their needs.


答:
The semi-official blog posts about Google recruitement recommands this book: The Algorithm Design Manual.

It's very comprehensive and well written, with a 'quick reference' part that can help a lot in your situation, once you're familiar enough with common algorithms and data structures.

Title: Preparing yourself for сode challenges

Body:
Just a few days ago I discovered Codility, and I tried their challenges. And I must say. I got my behind handed to me on a platter. I'm not sure what the problem was, but I'll lick my wounds and wait for the solution to come out and compare it with my own. In the meantime, I want to get ready for the next challenge so I'm reading their previous blog posts and seeing how to solve their previous problems. There are a lot of new things I haven't heard about like (Cartesian trees, various sort algorithms, etc.)

So, how does one prepare for such challenges (especially the O(x) time and space complexity). What should I read to prepare for such a task?


问:
What is the aim of software testing?
Having read many books, there is a basic contradiction:

Some say, "the goal of testing is to find bugs" while other say "the goal of the testing is to equalize the quality of the product", meaning that bugs are its by-products.

I would also agree that if testing would be aimed primarily on a bug hunt, who would do the actual verification and actually provide the information that the software is ready?

Even e.g. Kaner changed his original definition of testing goal from bug hunting to quality assessment provision but I still cannot see the clear difference. I perceive both as equally important.

I can verify software by its specification to make sure it works and in that case, bugs found are just by products. But also I perform tests just to break things.

Also what definition is more accurate?

Note above I am primarily referring to software testing as a process.

答:
As I'm sure you are aware, there are many different types of software testing, such as unit testing, integration testing, acceptance testing, etc.  So it's kind of an umbrella term for all of those, and at this very high level of discussion, we can only really talk about "quality", as a broad term.  You are simply validating the software against whatever measurements of acceptability you wish to apply.  At different levels and types of testing, these will vary greatly, and the only real common ground is the quality aspect.

Bugs (as traditionally defined) are a specific type of problem with the software, but there are many others.  Unless we're discussing a specific, lower level of testing, it doesn't make sense to limit the definition to bugs.  Is a UI which is a bit too slow a bug?  What about the fact that we forgot to tell the developers to add a basket to our web store?  Perhaps the confusion comes in with specific types of testing being referred to as "software testing", but it's really just semantics.

If pushed to formalise the definition, I would say that testing is a process of validating the software against your requirements (which can be qualitative, too).  A bug is just a very specific violation of requirements (specifically, one which the developer thought already worked correctly).

EDIT:  I should probably add that the word "bug" has very different meanings to different people, and we should actually start this semantic discussion by defining it.  I'm using the definition from a developer's perspective - this doesn't work as I (the developer) intended it.  It is typically based on either a very specific requirement, or a very specific interpretation of a requirement.  The client's definition is typically similar - this doesn't work as I (the client) intended it, which is a very different thing indeed.  Using the latter definition, you could almost equate quality and bugs, because anything that doesn't meet the client's wishes is a "bug".

Title: What is the aim of software testing?


问:
Naming for a REST webservice
I have a rest webservice with an endpoint www.foobar.com/service.svc/MAC  (migration authorisation code). Posting and getting to that adds and gets one MAC respectively. I now need to impliment a new enpoint for all MACs. What would that be? www.foobar.com/service.svc/MAC/All seems wrong. What would be correct and why?

答:
I posted a series of guidelines here: http://soaprobe.blogspot.co.uk/2012/10/soa-rest-service-naming-guideline.html

These are being used effectively,  where I work.

UPDATE - I pasted the contents into another answer....

Robert

Title: Naming for a REST webservice


问:
Why isn't functional language syntax more close to human language?
I'm interested in functional programming and decided to get head to head with Haskell. My head hurts... but I'll eventually get it...
I have one curiosity though, why is the syntax so cryptic (in lack of another word)?

Is there a reason why it isn't more expressive, more close to human language?

I understand that FP is good at modelling mathematical concepts and it borrowed some of it's concise means of expression, but still it's not math... it's a language.

答:
I'm currently getting to grips with Scala at the moment, so I can sympathise. At least with Scala I can fall back to an imperative style when the going gets too tough.

I think there are several forces at play here:

Designers of functional languages necessarily have a strong maths background, so
they borrow mathematical notation which is natural to them.

Greater expressiveness (i.e. power of statements, rather than
closeness to English) of any language has (IMO) a corresponding price
in steepness of learning curve. Terseness is a highly prized quality
in Scala, with many things being optional.

Functional languages just do things very differently, so the basic
operations don't map onto imperative constructs.


答:
Haskell syntax is close to human language. It is specifically designed to resemble mathematical notation, which is a language designed by humans (thus a human language) to express precisely those concepts that Haskell is built upon.

You can show a piece of Haskell code to any mathematician or logician, and he will be able to understand it, even if he has never ever heard of Haskell and knows absolutely nothing about programming, computer science or even computers.

On the other hand, you can show any mathematician or logician a piece of code like this:

```<code>x = x + 1
</code>```

and he will be utterly confused, saying: "This doesn't make sense, there is no x such that x equals x plus 1."

Whether or not some specific notation is "cryptic" or not, is a matter of opinion and familiarity.

Title: Why isn't functional language syntax more close to human language?

Body:
I'm interested in functional programming and decided to get head to head with Haskell. My head hurts... but I'll eventually get it...
I have one curiosity though, why is the syntax so cryptic (in lack of another word)?

Is there a reason why it isn't more expressive, more close to human language?

I understand that FP is good at modelling mathematical concepts and it borrowed some of it's concise means of expression, but still it's not math... it's a language.

Body:
Haskell syntax is close to human language. It is specifically designed to resemble mathematical notation, which is a language designed by humans (thus a human language) to express precisely those concepts that Haskell is built upon.

You can show a piece of Haskell code to any mathematician or logician, and he will be able to understand it, even if he has never ever heard of Haskell and knows absolutely nothing about programming, computer science or even computers.

On the other hand, you can show any mathematician or logician a piece of code like this:

x = x + 1

and he will be utterly confused, saying: "This doesn't make sense, there is no x such that x equals x plus 1."

Whether or not some specific notation is "cryptic" or not, is a matter of opinion and familiarity.


答:
One of my experiences that went well

The system was dead and unable to react to market changes, it was customer facing, looked and worked in an outdated way and had so many bug reports, that the estimated time to fixing them was more than rewriting the entire thing. Some lessons

The time estimation was wrong BUT

The new system had new/better features

It was really easy adding features

When a bug cropped up it was mostly fixed within an hour

The user experience was enhanced greatly, because designers had a chance to update the design.

Not so good experience

System was very buggy and had a horrible data model and data access layer. It was actually the technology used that was crippling it. There were discussions on using the current data model but they were abandoned. The new design was necessary to make new features possible.

The problems from the first system shined through. The reasons things were a mess is because the powers that be were not sure what they wanted.

Massive delays resulting from constant mind changing killed the project.

The software itself was running quite well, but the general feeling from everyone was not good.

A refactoring success

I've had a few systems handed to me that some would justify to be rewritten (some people are very over eager, and sometimes they simply want to do it because the code looks different).

The particular system was a mess. The layers were all mixed up with no distinguishable data access layer, controls on screens were named Button1, Button2... Variables were re-used, pieces of code were copied wholesale across different classes.

Using refactoring tools helped a lot, but essentially it took about 2 months of dedicated work, interspersed with bug fixes and enhancement requests. Essentially the project could keep running despite the massive internal overhaul. If you start small and fix the little things soon you realise that you can be comfortable working with something.

Lessons I've learned

Always try to think of every single reason not to rewrite. Think as hard as you can how you can save a dying system. You would be surprised how much less work it is than you think. Rewrites are a massive gamble, and in good company it will work well. Management usually tries to justify a rewrite by adding features to the new version. This could open up a nightmare of constant scope creep, what-if-we-had-stupid-feature-x, analysis paralysis and all the other bad things that come with a new project.

If your company is good at new projects and there is no way to save it then report on what is bad in the system. Show it to the your managers, get a third opinion from another developer,  and take it from there.


答: software testing is not aimed at finding bugs, it's aimed at preventing bugs. Proper testing in early stages prevents bugs making it into production systems.</p>

Title: What is the aim of software testing?

Body:
Having read many books, there is a basic contradiction:

Some say, "the goal of testing is to find bugs" while other say "the goal of the testing is to equalize the quality of the product", meaning that bugs are its by-products.

I would also agree that if testing would be aimed primarily on a bug hunt, who would do the actual verification and actually provide the information that the software is ready?

Even e.g. Kaner changed his original definition of testing goal from bug hunting to quality assessment provision but I still cannot see the clear difference. I perceive both as equally important.

I can verify software by its specification to make sure it works and in that case, bugs found are just by products. But also I perform tests just to break things.

Also what definition is more accurate?

Note above I am primarily referring to software testing as a process.


答:
If I understood your last comment correctly, your question is why Haskell often uses symbolic operators in places where it could as well use alphanumeric keywords (or function names)?

Regarding keywords one answer would be that keywords prevent you using certain words as variable names. For example I'm always annoyed when I want to call my variables from and to in a languages where one of those is a keywords - like in Python.

Another reason for symbolic operators in general is conciseness. That doesn't really apply in your specific examples of list comprehensions (<- isn't shorter than in), but in many cases it does.

Yet another reason is readability. That might seem counter-intuitive because symbolic operators are often harder to learn since their "names" don't really tell you anything about what they do (while a function's name usually will), but once you do know what a given operator does, expressions with infix symbolic operators are often easier to parse for a human than one with lots of alpha-numeric prefix function calls since the operators are more easily visually distinguished from the operands that way. For example most people would agree that 2 * 3 + 4 is more easily readable than add (mult 2 3) 4 or add(mult(2, 3), 4).


答:
Functional languages like Haskell and its antecedent Miranda grew out of the mathematical concept of lambda calculus. From the Wikipedia page:

Lambda calculus (also written as λ-calculus or called "the lambda calculus") is a formal system in mathematical logic for expressing computation by way of variable binding and substitution.

...

Lambda calculus has played an important role in the development of the theory of programming languages. The most prominent counterparts to lambda calculus in computer science are functional programming languages, which essentially implement the calculus (augmented with some constants and datatypes). Beyond programming languages, the lambda calculus also has many applications in proof theory. A major example of this is the Curry–Howard correspondence, which gives a correspondence between different systems of typed lambda calculus and systems of formal logic.

Because of this history, the syntaxes of these functional languages (and functional elements of more imperative languages) are strongly influenced by the mathematical notation used by lambda calculus.

The precision with which both mathematical notations and computer languages can describe requirements and the precision with which computers require their instructions to be written correlate well with each other. The imprecision of natural language however creates a huge barrier to it's use for programming computers. Even the (arguably) most successful Natural language programming environments such as Wolfram Alpha need significant domain experience to be used effectively.


答:
What is the aim of software testing?

In short: As question authors comment says "in general, software testing as a process." - Your question is broad, and here is its definition in Wikipedia article.

Software testing is an investigation conducted to provide stakeholders with information about the quality of the product or service under test. Software testing can also provide an objective, independent view of the software to allow the business to appreciate and understand the risks of software implementation.

Thus, aim of software testing is to provide independent information about the quality of the product/software. - How it needs to be done and sub-process of software testing? - is a different question to look for.

Edit: Software testing process needs to be provided independently based on business requirements. Otherwise, there would be less value in it. In fact, big scope software projects (like national real estate projects or similar) do have a separate biding for quality control, testing and software verification/acceptance processes.

Title: What is the aim of software testing?


答:
how does one prepare for such challenges (especially the O(x) time and space complexity). What should I read to prepare for such a task?

By getting prepared of course ! It is a matter of practice and getting up to speed about areas that you have felt short. Thanks God, pretty good resources to cover once information shortcomings are on the internet and Google is your friend.

Regarding references i would advice several web-sited that do have programmer challenge questions. From that question types you can determine your shortcomings and study for them.

Resources to look:

Programmer challenges

World’s Best Programmer challenge

Some programming challenge Q&A

Programming Challenges - Quora

Title: Preparing yourself for сode challenges


答:
It will depend on the project scope and the meeting agenda.

For all initial design meetings it might be waste of time to involve all team members, as some of this discussion would be really high topics for them. Instead, they may get simplified and easy to understand technical descriptions from Team Lead.

In addition, some of the decision made in that meeting might not seem logical for all developers. As each decision may take into account some non-technical considerations which are not openly discussed due to million of other reasons (company policy, confidentiality, etc.).


答:
I think Haskell gets as similar to human language as one can get without introducing a crazy syntax. It really goes great lengths towards this, for instance with the where clause to postpone a definition and with the list comprehension syntax which is exactly what I would write on a blackboard. It also avoid extraneous characters like braces and has a liberal use of indentation. The typical example is quicksort:

```<code>qsort [] = []
qsort (p:xs) = qsort lesser ++ [p] ++ qsort greater
               where lesser = [x | x <- xs, x <= p]
                     greater = [x | x <- xs, x > p]
</code>```

Admitted, it is a simple example, but I do not know any other language that gets it as readable as this is.

Doing more complicated stuff can become difficult to read in Haskell, but that has to do with the type system, the constrained IO and not with the syntax at all.

If anything, I would say that Haskell has sacrificed syntactic simplicity in order to accommodate a syntax which is more similar to human language. A language like scheme has a syntax that is very far from what a human would write, but it is really simple to explain its rules.

Body:
I think Haskell gets as similar to human language as one can get without introducing a crazy syntax. It really goes great lengths towards this, for instance with the where clause to postpone a definition and with the list comprehension syntax which is exactly what I would write on a blackboard. It also avoid extraneous characters like braces and has a liberal use of indentation. The typical example is quicksort:

qsort [] = []
qsort (p:xs) = qsort lesser ++ [p] ++ qsort greater
               where lesser = [x | x <- xs, x <= p]
                     greater = [x | x <- xs, x > p]

Admitted, it is a simple example, but I do not know any other language that gets it as readable as this is.

Doing more complicated stuff can become difficult to read in Haskell, but that has to do with the type system, the constrained IO and not with the syntax at all.

If anything, I would say that Haskell has sacrificed syntactic simplicity in order to accommodate a syntax which is more similar to human language. A language like scheme has a syntax that is very far from what a human would write, but it is really simple to explain its rules.


答:
From Daniel B's answer:

I'm using the definition from a developer's perspective - this doesn't work as I (the developer) intended it. It is typically based on either a very specific requirement, or a very specific interpretation of a requirement. The client's definition is typically similar - this doesn't work as I (the client) intended it, which is a very different thing indeed.

This is essentially the difference between verification and validation. Verification answers the question "Did we build it right?" Validation answers the question "Did we build the right thing?" Verification testing and validation testing are rather different things. Verification is a much easier task than validation. With verification, you know what to test against: the requirements (or stories) that spell out what the software is supposed to do. There's a problem here: What if those requirements or stories are wrong? How do you test that problem? That's what validation attempts to address.

Yet another component used in some circles is the concept of accreditation. This becomes important when software is reused. Example: Suppose you are building a simulation of a vehicle and need a good model of its inertial measurement unit. You find an existing IMU model in the components model library. This existing model has been thoroughly verified against requirements and validated against reality. The testing is very extensive, including comparisons against flight data. Verified and validated! Sounds good! Just reuse it as-is.

Then again, maybe not. The intended use of that model might have been quiescent operations, your use is to model a rocket during launch phase. The behavior of the IMU during launch will be close to spec behavior: in other words, lousy. IMUs typically perform much, much better than spec during quiescent operations. The intended use of that model does not match your intended use. You had better not reuse it. Accreditation attempts goes beyond verification and validation. It answers the question "Is this the right thing for this specific intended use?"

Another example is the first flight test of the Ariane 5 rocket. The software bug that led to the failure of flight 501 ranks as one of the most infamous and most expensive software bugs of all time. Flight software is extremely expensive to build. To avoid these huge costs, the Ariane 5 flight software reused big chunks of the Ariane 4 flight software. Extensively verified and validated, and already used in a real-world setting. So just reuse it as-is. Wrong. It should have been accredited for reuse. A supposedly "can't happen" event involving a 64 bit to 16 bit conversion overflow happened to happen, and the vehicle failed as a result.

Title: What is the aim of software testing?


问:
How can I reformat my condition to make it better?
I have a condition

```<code>if(exists && !isDirectory || !exists)
{}
</code>```

how can I modify it, so that it may be more understandable.

答:
|| is commutative so

```<code>if(!exists || (exists && !isDirectory))
</code>```

is equivalent.

Now because exists is always true in the second part of the || you can drop the &&:

```<code>if(!exists || !isDirectory)
</code>```

Or you can go a step further and do:

```<code>if(!(exists && isDirectory))
</code>```

Body:
|| is commutative so

if(!exists || (exists && !isDirectory))

is equivalent.

Now because exists is always true in the second part of the || you can drop the &&:

if(!exists || !isDirectory)

Or you can go a step further and do:

if(!(exists && isDirectory))


答:
For better readability, I like to extract boolean conditions to methods:

```<code>if(fileNameUnused())
{...}

public boolean fileNameUnused() {
   return exists && !isDirectory || !exists;
}
</code>```

Or with a better method name. If you can name this method properly, the reader of your code doesn´t need to figure out what the boolean condition means.

Title: How can I reformat my condition to make it better?

Body:
I have a condition

```<code>if(exists && !isDirectory || !exists)
{}
</code>```

how can I modify it, so that it may be more understandable.

Body:
For better readability, I like to extract boolean conditions to methods:

if(fileNameUnused())
{...}

public boolean fileNameUnused() {
   return exists && !isDirectory || !exists;
}

Or with a better method name. If you can name this method properly, the reader of your code doesn´t need to figure out what the boolean condition means.


答:
Domain modelling sessions abide by the same rules as any meeting - the more active participants, the messier the meeting. In my experience, you can't have a really focused and productive design session with more than one domain expert and one or two developers.

However, as you point out, the whole team needs a shared knowledge of the domain. This is where Agile planning and estimation meetings shine as a complement to smaller domain modelling sessions. Some time ahead of the start of a release, the domain expert will explain a group of features to all the team members using the ubiquitous language that took form during previous domain modelling sessions. Team members can give their feedback and propose new ideas, adjusting and enriching the ubiquitous language. Just before the start of an iteration, the whole team will again examine a subset of these features, re-estimate them and break them down into tasks, with the opportunity to make final adjustments to domain details.

The ubiquitous language and model pertaining to a feature or a set of features must go through several stages of refinement before they are ready to be implemented. These stages involve different people at different times. You don't have just one big bang meeting where everything is decided about the domain.


答:
You could just try to nail the no-go case and bail out if that shows up.

```<code>while(someCondition) {

    if(exists && isDirectory)
        continue;
        // maybe "break", depends on what you're after.

        // the rest of the code
}
</code>```

or even

```<code>function processFile(someFile)
{
    // ...
    if(exists && isDirectory)
       return false;
    // the rest of the code
    // ...
}
</code>```

Body:
You could just try to nail the no-go case and bail out if that shows up.

while(someCondition) {

    if(exists && isDirectory)
        continue;
        // maybe "break", depends on what you're after.

        // the rest of the code
}

or even

function processFile(someFile)
{
    // ...
    if(exists && isDirectory)
       return false;
    // the rest of the code
    // ...
}


答:
There is no reason you cannot address the problems that exist in your current project.  One does not need to throw the baby out with the bath water.  There are lots of ways you can address the problems that exist.  If you have a high level of defects then unit testing and validation and verification testing is one of those solutions.

The software lacks any meaningful architecture - there's no object
  orientation whatsoever, horrible amounts of cyclical dependencies and
  an over-reliance on global variables to name just a few things.
  Another huge thing for me is Delphi 7 does NOT support 64-bit.

Delphi supports nearly every modern programming concept that Java and C# support. This means you could easily solve your cyclical dependencies and global variable problem.  You could even solve your object orientation if you wanted.  All you would need to do is address a single problem at a time.

The problem here for me is that my management team don't care about
  technical things, they want to know why they should care. Obviously
  that's expected, so what I'm asking here is for some guidance, or
  tales, or pitfalls about this kind of thing.

You as their employee believe the software is unmaintainable.  You need to make a case for the reasons, you need to come up with a solution to the reasons the project is unmaintainable.  If you cannot do this then its very likely the project IS ACTUALLY MAINTAINABLE because it has been maintained for over 20 years.


问:
What functionality does dynamic typing allow?
I've been using python for a few days now and I think I understand the difference between dynamic and static typing. What I don't understand is under what circumstances it would be preferred. It is flexible and readable, but at the expense of more runtime checks and additional required unit testing.

Aside from non-functional criteria like flexibility and readability, what reasons are there to choose dynamic typing? What can I do with dynamic typing that isn't possible otherwise? What specific code example can you think of that illustrates a concrete advantage of dynamic typing?

答:
As someone mentioned, in theory there is no much you can do with dynamic typing that you could not do with static typing if you would implement certain mechanisms on your own. Most of languages provide the type relaxation mechanisms to support type flexibility like void pointers, and root Object type or empty interface.

Better question is why is dynamic typing more suitable and more appropriate in certain situations and problems.

First, lets define

Entity - I would need a general notion of some entity in the code. It can be anything from primitive number to complex data.

Behavior - lets say our entity has some state and a set of methods that allow outside world to instruct the entity to certain reactions. Lets call the state + interface of this entity its behavior. One entity can have more than one behavior combined in a certain way by the tools language provides.

Definitions of entities and their behaviors - every language provides some means of abstractions which help you to define behaviors (set of methods + internal state) of certain entities in the program. You can assign a name to these behaviors and say that all instances that have this behavior are of certain type.

This is probably something that is not that unfamiliar. And as you said you understood the difference, but still. Probably not complete and most accurate explanation but I hope fun enough to bring some value :)

Static typing - behavior of all entities in your program are examined in compile time, before code is started to run. This means that if you want for example your entity of type Person to have behavior (to behave like) Magician then you would have to define entity MagicianPerson and give it behaviors of a magician like throwMagic(). If you in your code, mistakenly tell to ordinary Person.throwMagic() compiler will tell you "Error >>> hell, this Person has no this behavior, dunno throwing magics, no run!".

Dynamic typing - in dynamic typing environments available behaviors of entities are not checked until you really try to do something with certain entity. Running Ruby code that asks a Person.throwMagic() will not be caught until your code really comes there. This sounds frustrating, isn't it. But it sounds revelational as well. Based on this property you can do interesting things. Like, lets say you design a game where anything can turn to Magician and you don't really know who will that be, until you come to the certain point in code. And then Frog comes and you say HeyYouConcreteInstanceOfFrog.include Magic and from then on this Frog becomes one particular Frog that has Magic powers. Other Frogs, still not. You see, in static typing languages, you would have to define this relation by some standard mean of combination of behaviors (like interface implementation). In dynamic typing language, you can do that in runtime and nobody will care.

Most of dynamic typing languages have mechanisms to provide a generic behavior that will catch  any message that is passed to their interface. For example Ruby method_missing and PHP __call if I remember good. That means that you can do any kind of interesting things in run time of the program and make type decision based on current program state. This brings tools for modeling of a problem that are lot more flexible than in, lets say, conservative static programming language like Java.


答:
Make sure no-one implemented what you're trying to do at home.

Make sure you're interested in what would be the result of your work at home.

Make sure other people than you think they would be interested to see the result of your work at home.

is to make your initial motivation boost enough to make you start the project.

is to make you plan and organize in a way that will make you avoid stoping the project each time you're blocked.

is to give your regular motivation boost on the long run.


问:
TypeScript or JavaScript for noob web developer
Following the recent release by Microsoft of TypeScript I was wondering if this is something that should be considered for a experienced WinForm and XAML developer looking to get into more web development.

From reviewing a number of sites and videos online it appears that the type system for TypeScript makes more sense to me as a thick client developer than the dynamic type system in Javascript.

I understand that Typescript compiles down to JavaScript but it appears that the learning curve is shallower due to the current tooling provided by Microsoft.

What are your thoughts?

答:
Those aren't going to be the two options for a while. If you use TypeScript, you're going to need to know JavaScript anyway because, for the foreseeable future, there isn't going to be a tool for debugging TypeScript in the form it was written.

So it's JavaScript or TypeScript AND JavaScript.

So I suggest learning JavaScript first while keeping an eye on what TypeScript offers. While you're at it, take a look at what jQuery and CoffeeScript offer. The three packages solve different problems so, when you run into one of those problems, you'll know which product to learn next.


问:
Is eval the defmacro of javascript?
In Common Lisp, defmacro basically allows us to build our own DSL.

I read this page today and it explains something cleverly done:

But I wasn't about to write out all these boring predicates myself, so I defined a function that, given a list of words, builds up the text for such a predicate automatically, and then evals it to produce a function.

Which just looks like defmacro to me.

Is eval the defmacro of javascript? Could it be used as such?

答:
It can, but it's more dangerous.

defmacro has three main features:

It runs at compile time;

It is a genuine in-place substitution; and

Because of the whole nature of Lisp syntax, it works at an AST level, not a source-code level.

By contrast, eval:

Executes at runtime;

Is not an in-place substitution; and

Works with strings.

Why does this matter?

First, eval has a speed penalty: because it has to evaluate its arguments every single time it's called, instead of just once at compile time, you'll have a speed hit on each run of the program.

Second, there is no compile-time validation that the eval is actually getting passed something sane.  You can have a horrible syntax error in your eval argument (or, worse, a horrible syntax error only when called in certain ways), but it won't be caught until runtime far down the road.  Because Lisp macros are compile-time, you can't have that.  Your macro might not work, mind you, but it'll compile by definition to something valid.

Third, eval has serious safety issues compared to defmacro.  Because Lisp macros work with the AST, there's a high degree of safety.  No matter what argument you supply the macro at runtime, those arguments can't allow a malicious caller to "escape" the macro, or call malicious code.  That's not true of eval: if you don't think through your string escapes very, very carefully, and you allow any form of user-generated input into the eval string, you're risking allowing malicious code to run.

Okay, but, whatever, I can hear you say.  The user would have to do that to himself, and it's already his browser, so why care?

Because there are lots of ways to inject scripts in that situation.  Cross-site script requests, for example, or forgetting to escape a string properly that you store in a database.  There are lots of ways of getting malicious values into those macros--and the moment that happens, your users' data is toast.

Finally, even if all of that doesn't dissuade you, JavaScript's eval in particular is simply less powerful.  There are odd ways that it interacts with the enclosing variable scope and the global variable scope, for example, and there's no sane way to do the equivalent of Common Lisp's gensym for variable hygiene.

Can you use eval in some of the places you might use defmacro?  Sure.  But they are hardly interchangeable, and I hope that the above explanation makes it clear why absolutely zero good JavaScript frameworks I know use eval.

Instead, if you really find yourself wanting macros, go find a compiles-to-JavaScript language that has them, such as ClojureScript.  That way, you'll get the benefits of Lisp macros without the drawbacks of eval.

Title: Is eval the defmacro of javascript?


答:
As eval can execute arbitrary javascript I'm sure you could put something together similar to a macro system. That being said, javascript is not homoiconic in the same way as Common Lisp or Scheme. Homoiconicity(?) is the fancy term for the old list mantra of "Code as data". A macro system transforms code. This is very natural when you can maniplate code in the same way that you manipulate other data because everything is a list (LISt Proccessing). We can list many ways in which javascript "is a lisp", but it does not treat code as data.

In a lisp macro system, we manipulate lists. In a "javascript macro system" (notice the quotes) we have to manipulate strings or some complicated AST.

There's a famous antecdote where someone is giving a talk on all the ways that Python is a lisp "first class functions blah blah blah". At the end, John McCarthy (inventor of Lisp) raises his hand and asks "Does it treat code as data?" Zing.

In conclusion, eval could probably be used to tack a macro system onto javascript. But it would not be as natural as Common Lisp's defmacro.

Title: Is eval the defmacro of javascript?

Body:
In Common Lisp, defmacro basically allows us to build our own DSL.

I read this page today and it explains something cleverly done:

But I wasn't about to write out all these boring predicates myself, so I defined a function that, given a list of words, builds up the text for such a predicate automatically, and then evals it to produce a function.

Which just looks like defmacro to me.

Is eval the defmacro of javascript? Could it be used as such?


答:
Identify software regressions as soon as they present themselves.

Unit Testing, in particular, is meant to identify regressions early in the building/testing/deploying chain

Acceptance Testing is more on the lines of fullfilling a contract with a client. But then again, if one part of an acceptance test doesn't pass while it was instead supposed to, you have identified a regression to handle.

Title: What is the aim of software testing?


问:
Estimation Techniques for Linux Kernel Development
I am working in Linux Kernel area and my work includes:
code study / Understanding
Porting (say from one kernel version to another kernel version)
Implementation of new kernel module / Device driver

How to do estimation in such Linux Kernel assignments? Is there any technique? How the community is doing?

答:
Joel Spolsky has written about the wide range of programmer productivity, so there could be a huge range in how much time it takes one person vs. another.

I know of a Linux kernel course that was taught at a university and it was split up to take two semesters.  In theory, that is 6 credit hours.  Courses generally involve one hour instruction per week per credit hour, so the lecture part of this course is 15 weeks * 3 hours = 45 * 2 semesters = 90 hours, with expected prep of perhaps three hours outside class per hour spent in class = 270 hours, for a total of 360 hours.  This is a pretty gross estimate, but if you really wanted to learn the subject, between reading, homework, programming assignments, and studying for exams and quizes, you could spend nine hours per week.  But, I still believe in the old fashioned rule that you get out of it what you put into it.  Or perhaps more accurately, you don't get out what you don't put in.

A sample syllabus for a one semester course can be found at http://www.citidel.org/bitstream/10117/3539/1/82-index.html


问:
How show Attributes which appear In Many To Many association
As we know a many to many association are shown by two asterisks in both end of association. Now I have a association between two entities "Good" and "Invoice" so Good and Invoice have a many to many association but I want to show the "count of each good" in each invoice on class diagram.

How can I show it?

答:
Often times many to many associations indicate the need for a third entity.

You need InvoiceDetail entity.

Anyway "count of each good" should be a method in class Invoice.

```<code>public int getCountOfGood(Good good);
</code>```

there can also be a method that returns a data structure with the count of each distinct Good in the Invoice

```<code>public Map<Good><Integer> getCountOfEachGood();
</code>```

Good entity is oblivious of Invoice.

Body:
Often times many to many associations indicate the need for a third entity.

You need InvoiceDetail entity.

Anyway "count of each good" should be a method in class Invoice.

public int getCountOfGood(Good good);

there can also be a method that returns a data structure with the count of each distinct Good in the Invoice

public Map<Good><Integer> getCountOfEachGood();

Good entity is oblivious of Invoice.


问:
The 10 minutes technical interview
I must do a quick assessment of dozens of fresh students very quickly. I have 30 minutes meeting with each of them (in two or three days). I want to use most of the time to discuss non technical aspects. So I plan to use 10 minutes for technical questions. The same questions for all of them.

They are all hired already (they are students), what I need to know is the average level in order to prepare a training.

Ideally, the difficulty must be progressive in order to set a level for each. Level I will average, and I'll do an average on each question too.

If you had only 10 minutes and 10 questions to ask to a candidate, what would be your top 10 ?

答:
Without an answer to my comment above, these are things that come to mind generally speaking but I am not sure I would consider these technical.

What type of version control have you used?

Are you familiar with software development methodologies such as agile, waterfall, tdd?

What is the purpose of documentation in software?

Difference between statically and dynamically typed languages?

Title: The 10 minutes technical interview


答:
You can use an association class as depicted e.g. here: http://www.agilemodeling.com/style/classDiagram.htm

Using a new class and two associations inbetween like user1598390 described is valid as well. It depends how you would like to see the relationship between your entities. UML-wise association classes are probably more concise. Regarding the implementation in a programming language both solutions might even look the same (implemented with an additional link object as most programming languages don't support attributed links or pointers).

Title: How show Attributes which appear In Many To Many association

Body:
As we know a many to many association are shown by two asterisks in both end of association. Now I have a association between two entities "Good" and "Invoice" so Good and Invoice have a many to many association but I want to show the "count of each good" in each invoice on class diagram.

How can I show it?


答:
I think one thing you're probably running into is something that I ran into too when learning functional programming, which is that with functional programming you can (and almost have to) think/work at a higher level than you do with imperative programming.

What you're finding as less expressive, I think is actually more expressive: you don't have to spell out every little detail and can do more with less code in functional programming -- there's more power to what you write.

For example, I could write imperatively:

```<code>for each (Person person in people)
    print(person.name)
</code>```

which is totally legible as English.

A Haskell version might be (and this is not valid Haskell, but is just for syntactic comparison):

```<code>map (print . name) people
</code>```

which requires less code and less detail wrangling -- I don't have to break things down into a loop and its variable(s) (for each (...)), the map function takes care of that for me.

Working at that level can take some getting used to. If it helps any, Haskell was probably the toughest time I've had learning a new language since I started programming, and I know >10 languages (including Lisp). It was totally worth learning though.

Body:
I think one thing you're probably running into is something that I ran into too when learning functional programming, which is that with functional programming you can (and almost have to) think/work at a higher level than you do with imperative programming.

What you're finding as less expressive, I think is actually more expressive: you don't have to spell out every little detail and can do more with less code in functional programming -- there's more power to what you write.

For example, I could write imperatively:

for each (Person person in people)
    print(person.name)

which is totally legible as English.

A Haskell version might be (and this is not valid Haskell, but is just for syntactic comparison):

map (print . name) people

which requires less code and less detail wrangling -- I don't have to break things down into a loop and its variable(s) (for each (...)), the map function takes care of that for me.

Working at that level can take some getting used to. If it helps any, Haskell was probably the toughest time I've had learning a new language since I started programming, and I know >10 languages (including Lisp). It was totally worth learning though.