答:
Stick to the naming conventions specific to the platform you're using.

It's easy enough for any developer with an IDE to see if a method or class comes from the SDK, a third party library or your own code. It's usually as easy as mousing over the code and seeing a qualified name.

Besides, I don't think it's really that important for a developer to tell the difference between framework code and custom code. As long as they know the API and what the method is supposed to do, it shouldn't really matter. I very much prefer for it to be obvious (and indicated by naming conventions) which piece of code mentions a name of a class, a method, invokes a constructor, accesses a field or a static nested class.

These conventions will be different across languages but in my opinion, you should keep your code consistent with them.

Would this create mental overhead & confusion or would it really simplify things?

I would certainly perceive this as a source of confusion.

Title: Capitalizing custom methods in a SDK based project

Body:
In projects which need heavy SDK usage, like Android and iOS development, I want the methods/functions I write to be obvious and since the whole framework is written with lower case method names I would like to have my method names start with upper case.

However is this a good approach if there are going to be other programmers included in the project? Would this create mental overhead & confusion or would it really simplify things?

```<code>{
    didReceiveMemoryWarning(); // obviously a framework method
    MemoryWarning(); // obviously custom method

    item.height(); // obviously a framework method
    item.SeventhDimensionOfItem(); // obviously custom extension
}
</code>```


问:
Deciding How To Split Up Architecture Using If Blocks
I'm having trouble deciding the best way to handle splitting up if block checks for different architectures.  I may be handling the scenario completely wrong, so let me know if that is the case, or if this is a duplicate.

As a simple example, suppose we have two parameters to consider for a web script: member status (non-member, member type-A, type-B, type-C) and form submission/non-form submission. Forms may be submitted by both members and non-members. Currently, the script would ideally be split up as such:

```<code>Members (A, B, C)
    ->Non-Forms
    ->Forms
Non-Members
    ->Non-Forms
    ->Forms
</code>```

...however, it could be set up the other way:

```<code>Forms
    ->Members
    ->Non-Members
Non-Forms
    ->Members
    ->Non-Members
</code>```

I suppose this is a specific case, so there will be considerations for why you may or may not want to process forms before other tasks, etc. However, I am looking for the general criteria for deciding such architecture division schemes in the future, not considering special case with obvious considerations, so that I can figure it out for myself. (Note: Security is, of course, a concern in this situation so there is good cause to seperate member and non-member functionalities, which is something I might consider as an 'obvious consideration'. If you have anything you want to add for this case, though, I will be all eyes.)

答:
The best way to design your software for this instance would be to do so from a Domain Model driven approach.  Essentially design your domain model and relationships between entities in your domain model.  Persistence, events, business logic, security, view and controller logic can all be determined after the fact.

Example:

Submission: properties common between Form's and Non-Forms

Person?: properties common between Members and Non-Members

Form: Extends Submission, has reference to a Person, properties of a Form

Non-Form: Extends Submission, has reference to a Person, properties of a Non-Form

Member: Extends Person, properties of a Member

Non-Member: Extends Person, properties of a Non-Member

Now that you have defined your domain model and relationships between them, it becomes the logical next step to consider other aspects of your design.  What are the clearly defined behaviors of a Non-Form over a Form?  Define these behaviours in code.  What business logic should execute on the event of submission of a Form?  Code it.  Security can be engrained of course, you consider behaviors that differ between a Member and a Non-Member as part of your business logic.  Of course don't forget to thoroughly unit test all of your application behaviors.

The most important thing in your design is to DEFINE your domain model, only then should you consider behaviors.

ContentLicense: CC BY-SA 3.0


问:
Two way Communication between Server and Clients
Situation: We have a web application running on a server. This application needs to fetch data from some other PC(Clients), which are on a different network.

On the clients' pc there are WCF hosted in Windows Services using its their local Sql db. i want to make duplex communication between server and clients for share data with each other. data share mean share data-table,data-set,string etc between clients and server .

Problem :

1) I have no control over the firewall, proxy, NAT on the client side PC. Mostly company Employee PCs have lots of network security e.g firewall block ICMP traffic and some port too, some Router might be Disabled port-forwarding etc etc , client can change network place. I don't want to make any setting on client side Router,proxy,firewall though . during communication how can i handle that's kind of issue of client side? as you know skype is working perfect in that situation.

firewalls very often block inbound connections to clients; the client may not be reachable from the server, it may be using NAT translation behind a router and so cannot be contacted without port forwarding being set up on the router and some new router disabled port forwarding .

2) On clients side there is no IIS .

I don't want to allow remote access on clients PC.

There are more than 100 Clients and only one Server. one server need communicate with many clients on different network .

3) One side my client application is using window application and wcf hosted in window service ,Other side on my server i'm using Web application . so its mean communication is between desktop pc and web pc , that's issue .

If both using a web application then it was not issue to make duplex communication.because i know WEBRTC is fit there lol.

Technology which i had already test and find issue

WSDualHttpBinding: Not work if client behind NAT.

MSMQ : its bad technique if clients more than 1 and performance issue also because its use RAM memory .

Xsocket: Its also not work if ICMP traffic block by firewall on client.

WebRTC: Its work fine but its support web to web communication .as my client side i have win app.

Socket.io: Its need to set up node.js and many other thing , hard to implement because i need implement on existence application , i am not making new application.

C# Socket Program: Its not work if client and sever on different network .

Service Bus relay: Its not free even for testing .

socketPro: I studied i find its good but i can't find any right sample on google .so that i could test that.

Genuine Channels: I can't find any sample on google .

Lets see SignalR issue which i get.: Server side i run a console application and Client side i run two application ,one is console and other web. when i was running console client application than it was not initiating connection with Server but when i was using web client application then it was working fine. I can't understand why thas??

Please tell me What is best most secure and fast way to handle this situation? what approach should i use ?

Thanks Advance .

答:
This can be done using a WCF CallBack contract.

If the client can make a connection to the server, the server can use a WCF service with a callback construction. This describes that the server expects the client to implement a service as well (the callback service), as part of the service contract.

This beaks down as follows:

The server hosts a WCF service.

The service contract has a CallBackContract attribute:

[ServiceContract(CallbackContract = typeof(IMyServiceCallback))]

Clients that want to use this service, must implement the desired callback contract (service) to be able to communicate with the server.

When a client connect with the server side service, the reverse / callback connection will be made over the same connection.

Using callbacks is done over the same connection (that has already been opened). This requires a two-way communication channel (for example http).

See http://adamprescott.net/2012/08/15/a-simple-wcf-service-callback-example/ for an example how to implement this.


问:
Is there a conventional way to combine file path strings?
In an example:

```<code>var assets = "images/"

var sounds = assets+"sounds/"
</code>```

Is it more conventional to put the slash on the back of a file path?

```<code>var assets = "/images"

var sounds = assets+"/sounds"
</code>```

Is there another method that is a good common practice?

答:
Folders and files differ only in one aspect: folders end with a slash where files do not. Furthermore, absolute paths begin with a / where relative paths do not. If you use this consistently concatenating paths and files together should be no problem.

```<code>var absolutepath = "/my/path/";
var relativepath = "css/";
var filename = "test.css";
var relativepathtofilename = "js/test.js";

var a = absolutepath + relativepath + filename; //Output: /my/path/css/test.css
var b = absolutepath + relativepathtofilename;  //Output: /my/path/js/test.js
</code>```

Concatenating two absolute paths together makes no sense, since the second path should be relative to the first path. Concatenating two relative paths together is no problem, but might lead to undefined behavior if the program does not know where the relative path is relative to.

Body:
Folders and files differ only in one aspect: folders end with a slash where files do not. Furthermore, absolute paths begin with a / where relative paths do not. If you use this consistently concatenating paths and files together should be no problem.

var absolutepath = "/my/path/";
var relativepath = "css/";
var filename = "test.css";
var relativepathtofilename = "js/test.js";

var a = absolutepath + relativepath + filename; //Output: /my/path/css/test.css
var b = absolutepath + relativepathtofilename;  //Output: /my/path/js/test.js

Concatenating two absolute paths together makes no sense, since the second path should be relative to the first path. Concatenating two relative paths together is no problem, but might lead to undefined behavior if the program does not know where the relative path is relative to.


问:
Is there still a need for writing SQL?
With so many ORM tools for most modern languages, is there still a use case for writing and executing SQL in a program, in a language/environment that supports them?  If so why?

For clarity: I'm not asking about if programmers need to know SQL, or if I should have a SQL tool on my desktop.  I'm asking specifically why I might have it in code (or config, or whatever) as opposed to an ORM.

答:
Yes you can avoid writing SQL. But you will end up writing HQL instead (or Linq, or DQL...)!

Seriously, I'm am a big fan of ORMs, and I do think one may avoid using pure SQL most of the time. But we must remember that an ORM is just one big abstraction, and all big abstractions leak...

(But about the N + 1 problem: this is lazy-loading related, and most ORM tools have some way of requesting eager-loading, thus avoiding that particular issue.)

ContentLicense: CC BY-SA 2.5

Title: Is there still a need for writing SQL?


问:
What is the advantage of 'SwingUtilities.invokeLater()' method?
For the below sample GUI program using javax.swing,

```<code>public class UnResponsiveUI extends JFrame{

    private boolean stop = false;
    private JTextField tfCount;
    private int count = 1;

    /* Constructor to setup the GUI components */
    public UnResponsiveUI(){
        Container cp = this.getContentPane();
        cp.setLayout(new FlowLayout(FlowLayout.CENTER, 10, 10));
        cp.add(new JLabel("Counter"));
        tfCount = new JTextField(count + "", 10);
        tfCount.setEditable(false);
        cp.add(tfCount);

        JButton btnStart = new JButton("Start Counting");
        cp.add(btnStart);
        btnStart.addActionListener(new ActionListener(){
            @Override
            public void actionPerformed(ActionEvent e) {
                stop = false;
                for (int i = 0; i < 100000; ++i) {
                   if (stop) break;  // check if STOP button has been pushed,
                                     //  which changes the stop flag to true
                   tfCount.setText(count + "");
                   ++count;
                }
            }
        });

        JButton btnStop = new JButton("Stop Counting");
        cp.add(btnStop);
        btnStop.addActionListener(new ActionListener(){
            @Override
             public void actionPerformed(ActionEvent evt) {
                stop = true;  // set the stop flag
             }
        });

        setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
        setTitle("Counter");
        setSize(300, 120);
        setVisible(true);
    }

    public static void main(String[] args){
        /*SwingUtilities.invokeLater(new Runnable(){
            public void run() {
                new UnResponsiveUI();  // Let the constructor do the job
             }
        });*/

        /* new UnResponsiveUI(); */

        System.out.println("main thread exits");

    }

}
</code>```

In first scenario, After debugging the constructor invoked from main() as new UnResponsiveUI();,  Following is the observation wrt number of threads get launched:

1. The main() method starts in the "main" thread.

2. A new thread "AWT-Windows" (Daemon thread) is started when we step-into the constructor "new UnresponsiveUI()" (because of the "extends JFrame").

3. After executing "setVisible(true)", another two threads are created - "AWT-Shutdown" and "AWT-EventQueue-0" (i.e., the EDT).

4. The "main" thread exits after the main() method completes. A new thread called "DestroyJavaVM" is created.

5. At this point, there are 4 threads running - "AWT-Windows", "AWT-Shutdown" and "AWT-EventQueue-0 (EDT)" and "DestroyJavaVM".

6. Clicking the START button invokes the actionPerformed() in the EDT.

In second scenario, After debugging the constructor from main() invoked as,

```<code>SwingUtilities.invokeLater(new Runnable(){
            public void run() {
                new UnResponsiveUI();  // Let the constructor do the job
             }
        });
</code>```

Following is observation wrt number of threads get launched but at different time instances:

1. The main() method is started in the "main" thread.

2. The JRE's windowing subsystem, via SwingUtilities.invokeLater(), starts 3 threads at a time: "AWT-Windows" (daemon thread), "AWT-Shutdown" and "AWT-EventQueue-0". The "AWT-EventQueue-0" is known as the Event-Dispatching Thread (EDT), which is the one and only thread responsible for handling all the events (such as clicking of buttons) and refreshing the display to ensure thread safety in GUI operations and manipulating GUI components.

3. Then we step-into the constructor UnresponsiveUI()to run on the Event-Dispatching thread (created via invokeLater()), after all the existing events have been processed.

4. The "main" thread exits after the main() method completes.

5. A new thread called "DestroyJavaVM" is created.

So, In above two scenarios, The total number of threads getting created are same, but at different time instance and run GUI constructor on same EDT.

From this query, i learnt that: "If you didn't use invokeLater and instead you just updated the ui directly you might have a race condition and undefined behavior could occur."

My question:

What is the advantage of using SwingUtilities.invokeLater() method? Because in second scenario, launching EDT before stepping-into constructor did not add any value.

答:
Using SwingUtilities.invokeLater() is not merely advantageous, it's essential, but to understand why you need to understand Swing's threading model.

Updates to the GUI, via Swing, must occur on the Event Dispatch Thread (EDT), and code that does anything else (e.g. accessing some resource such as a database) should use one or more other threads.

invokeLater() enables these other threads to update the GUI with their results, in the EDT, e.g. showing the result of a database query.

invokeLater() is named this way to make it obvious that it is asynchronous in invoking the Runnable object you give to it, since the EDT may be busy at the time - it's not that you explicitly want  it to happen later.


问:
What would be good factual arguments to convince high level management to consider functional programming?
There are tons of "theoretical" arguments for why functional programming is a Good idea (too many for that to have stayed as an open question, and correctly so).

However, most of them are arguments either made from theory ("elegance", etc...), or, aimed at developers.

The problem is, most of them are entirely useless when one's goal is to present the idea to senior management of a large company, some of whom aren't even developers, and all of whom mostly care about business arguments: cost, human capital management, product delivery, client service and revenue; as well as quantitative facts over theoretical points that can't quite be backed up with facts.

Are there any compelling arguments to present to address those business concerns as far as considering adoption of functional programming as a concept (not any specific language), vs. the typical mix of procedural/OOP, e.g. Java/C++/(Perl|Python).

Preferably, I am looking for arguments that are quantitative and/or based on research or case studies. E.g. "according to this reference, the bug rate of multithreaded systems in Lisp/F# is 10% that of Java" or "80% of top graduates expressing preferences of desired technology named functional programing as on of top 3 interests".

I know that Graham presented use cases of functional programming for a starup and would be open to some of his arguments assuming they can be valid for a larger established company.

p.s.I'm perfectly aware that you can do something close to functional programming in Perl, likely Python, and (possibly) even Java 8 or C++ 14. But that doesn't mean that an organization using Perl, C++ or Java would endorse functional vs OOP/procedural approaches even in those languages

For the purposes of this language, "large" is defined as large enough to have dedicated development engineering/tools group, which dictates what all the developers are allowed to use/do; and at least hundreds of developers on low end.

答:
Senior management with no technical skills shouldn't care about technical aspects such as the usage of functional paradigms. This is not their domain of expertise, and smells micromanagement. Why aren't they delegating those decisions to persons who actually have required skills?

This being said, here are some hints to convince people with technical background (first case) and those without one (second case).

First case

If you're talking to people who know programming, comparing code written without functional programming paradigms and the same code written in functional style may be convincing enough:

Sample C# code which uses imperative style:

var categorizedProducts = new Dictionary<string, List<Product>>();

// Get only enabled products, filtering the disabled ones, and group them by categories.
foreach (var product in this.Data.Products)
{
    if (product.IsEnabled)
    {
        if (!categorizedProducts.ContainsKey(product.Category))
        {
            // The category is missing. Create one.
            categorizedProducts.Add(product.Category, new List<Product>());
        }

        categorizedProducts[product.Category].Add(product);
    }
}

// Walk through the categories.
foreach (var productsInCategory in categorizedProducts)
{
    var minimumPrice = double.MaxValue;
    var maximumPrice = double.MinValue;

    // Walk through the products in a category to search for the maximum and minimum prices.
    foreach (var product in productsInCategory.Value)
    {
        if (product.Price < minimumPrice)
        {
            minimumPrice = product.Price;
        }

        if (product.Price > maximumPrice)
        {
            maximumPrice = product.Price;
        }
    }

    yield return new PricesPerCategory(category: productsInCategory.Key, minimum: minimumPrice, maximum: maximumPrice);
}
```

<p>Same code rewritten with functional programming in mind:</p>

<pre class="lang-cs prettyprint-override"><code>return this.Data.Products
    .Where(product => product.IsEnabled)
    .GroupBy(product => product.Category)
    .Select(productsInCategory => new PricesPerCategory(
              category: productsInCategory.Key,
              minimum:  productsInCategory.Value.Min(product => product.Price),
              maximum:  productsInCategory.Value.Max(product => product.Price))
    );
</code>```

Then ask them:

How many mistakes can a programmer make in the first sample? What about the second one?

How difficult is it to spot mistakes?

How difficult is it to modify code?

All three factors influence productivity, and so the cost of the product.

Second case

If you're dealing with people who don't know programming, there is no much technical stuff you can tell them. One of the ways to be convincing is to show the actual impact of functional paradigms on your work and the work of your coworkers.

For example, compare two projects made by the same team, one using FP, other not using it. Showing that the number of bugs is much lower or that this was the first project the company actually delivered on time should be convincing enough.

Body:
Senior management with no technical skills shouldn't care about technical aspects such as the usage of functional paradigms. This is not their domain of expertise, and smells micromanagement. Why aren't they delegating those decisions to persons who actually have required skills?

This being said, here are some hints to convince people with technical background (first case) and those without one (second case).

First case

If you're talking to people who know programming, comparing code written without functional programming paradigms and the same code written in functional style may be convincing enough:

Sample C# code which uses imperative style:

var categorizedProducts = new Dictionary<string, List<Product>>();

// Get only enabled products, filtering the disabled ones, and group them by categories.
foreach (var product in this.Data.Products)
{
    if (product.IsEnabled)
    {
        if (!categorizedProducts.ContainsKey(product.Category))
        {
            // The category is missing. Create one.
            categorizedProducts.Add(product.Category, new List<Product>());
        }

        categorizedProducts[product.Category].Add(product);
    }
}

// Walk through the categories.
foreach (var productsInCategory in categorizedProducts)
{
    var minimumPrice = double.MaxValue;
    var maximumPrice = double.MinValue;

    // Walk through the products in a category to search for the maximum and minimum prices.
    foreach (var product in productsInCategory.Value)
    {
        if (product.Price < minimumPrice)
        {
            minimumPrice = product.Price;
        }

        if (product.Price > maximumPrice)
        {
            maximumPrice = product.Price;
        }
    }

    yield return new PricesPerCategory(category: productsInCategory.Key, minimum: minimumPrice, maximum: maximumPrice);
}

Same code rewritten with functional programming in mind:

return this.Data.Products
    .Where(product => product.IsEnabled)
    .GroupBy(product => product.Category)
    .Select(productsInCategory => new PricesPerCategory(
              category: productsInCategory.Key,
              minimum:  productsInCategory.Value.Min(product => product.Price),
              maximum:  productsInCategory.Value.Max(product => product.Price))
    );

Then ask them:

How many mistakes can a programmer make in the first sample? What about the second one?

How difficult is it to spot mistakes?

How difficult is it to modify code?

All three factors influence productivity, and so the cost of the product.

Second case

If you're dealing with people who don't know programming, there is no much technical stuff you can tell them. One of the ways to be convincing is to show the actual impact of functional paradigms on your work and the work of your coworkers.

For example, compare two projects made by the same team, one using FP, other not using it. Showing that the number of bugs is much lower or that this was the first project the company actually delivered on time should be convincing enough.


答:
You are approaching this from the wrong side. In most companies, management is not responsible for "choosing the programming paradigm", they are (or at least should be) responsible for making the team work efficient. If your whole team is convinced functional programming will improve the speed or quality of your work, it should not be too hard to convince management, too. Moreover, if your team just starts to use functional constructs in your established programming languages, and everybody is happy with that, you should not even have to ask for a permission (heck, a non-programmer might not even understand the difference between non-functional and functional constructs, so why do you want to discuss that issue with him?).

But beware, if the rest of your team has a different opinion about FP, and they start complaining about functional code of yours which other team members do not understand, you might run into trouble with management - for a good reason, since in such a case, the team looses efficiency.

So the gist is: convince other team members, or your team leaders, but, not high-level management!

EDIT: due to your comment - actually, this is an answer to your question ;-). The one factual argument I am talking about is "the whole team thinks FP is helpful for doing the job. IMHO that's the argument with the highest chance of beeing accepted by high level management, and it is very practically applyable. Trying to use technical arguments to non-technical people directly seldom works, not because they are "too dumb to understand the technical reasoning", but because they are smart enough to know that technical decisions should be made by technical experts, and they are also smart enough not to rely on the opinion of only one expert.

Title: What would be good factual arguments to convince high level management to consider functional programming?

Body:
There are tons of "theoretical" arguments for why functional programming is a Good idea (too many for that to have stayed as an open question, and correctly so).

However, most of them are arguments either made from theory ("elegance", etc...), or, aimed at developers.

The problem is, most of them are entirely useless when one's goal is to present the idea to senior management of a large company, some of whom aren't even developers, and all of whom mostly care about business arguments: cost, human capital management, product delivery, client service and revenue; as well as quantitative facts over theoretical points that can't quite be backed up with facts.

Are there any compelling arguments to present to address those business concerns as far as considering adoption of functional programming as a concept (not any specific language), vs. the typical mix of procedural/OOP, e.g. Java/C++/(Perl|Python).

Preferably, I am looking for arguments that are quantitative and/or based on research or case studies. E.g. "according to this reference, the bug rate of multithreaded systems in Lisp/F# is 10% that of Java" or "80% of top graduates expressing preferences of desired technology named functional programing as on of top 3 interests".

I know that Graham presented use cases of functional programming for a starup and would be open to some of his arguments assuming they can be valid for a larger established company.

p.s.I'm perfectly aware that you can do something close to functional programming in Perl, likely Python, and (possibly) even Java 8 or C++ 14. But that doesn't mean that an organization using Perl, C++ or Java would endorse functional vs OOP/procedural approaches even in those languages

For the purposes of this language, "large" is defined as large enough to have dedicated development engineering/tools group, which dictates what all the developers are allowed to use/do; and at least hundreds of developers on low end.


答:
To understand why Functional Programming hasn't taken over the world, you have to understand the corporate thinking behind programming language decisions.  To pick on Java for a moment:

There are armies of programmers available that can write reams of ordinary Java code.  This is not true of Lisp or Haskell (or even Scala) programmers.

Everyone else is using Java, so it must be good. Corrolary: managers don't have to justify their choice of Java versus some obscure language nobody in the command structure has ever heard of.

If your organization is already entrenched in the Kingdom of Nouns, making a wholesale change to Functional Programming is just not going to happen.  The language choice (and all the other choices that surround it) is already deeply embedded in the corporate culture.

Assuming your goal is to grow as a software developer, your best bet is to

Incorporate functional concepts into your existing programs where they are useful and appropriate,

Use new functional language features as they are added to the language, and

Learn object-oriented design patterns, some of which exist to overcome the language deficiencies in OO languages that are not present in Functional languages.

Paul Graham's arguments really only apply to startups, and there have been a number of cautionary tales of companies that started out using purely Functional languages, but then they got bought out by another company whose first order of business was to immediately convert the functional code base to an OO language so that their existing software developers could understand it.


答:
Things to consider for upper management when/if upper management is involved in selecting programming languages (which is odd, they should leave it to trusted, knowledgeable people (both technology and business savvy):

Productivity

Both current and future employees

All roles (architects, developers, testers, OPs, ...)

Supported platforms

Operating systems, (hardware?)

Publisher of the language/platform

Licences

Maturity of the language/platform

Support of/by the publisher and/or community

Libraries

Migrating current code base

Or integration with

Note that these are not specific to functional programming languages. These are also no arguments unless you provide data with these. We cannot give you the data as they completely depend on your business' environment. The only thing we could do is collect data from the web to show how much knowledge and interest there is for a specific language. Be careful when translating many questions on StackOverflow or many tags on Linkedin into a language being popular.


答:
One good approach would be to show that it's shown good results in the industry and adopted.

You can get some data from:

http://www.quora.com/What-companies-use-a-functional-language-as-an-official-language

http://pchristensen.com/blog/lisp-companies/

Ideally, try to talk to the managers at some listed companies, especially if in your industry, and get numbers and testimonials from them.

Google has many other similar links for Haskell, OCaml, etc.


问:
Do I need Bower for front end dependencies when I am already using composer?
I use composer for PHP dependencies. I was under the impression that for front end dependencies I should use Bower. So, I installed Bower and loaded my FE dependencies (Bootstrap, jQuery) using that. I then manually symlink to the libraries as follows:

```<code>mypc:/var/www/myproject/public/js$ ls -l
total 8
lrwxrwxrwx 1 tom tom   67 Dec 23 07:29 bootstrap.min.js -> /var/www/myproject/bower_components/bootstrap/dist/js/bootstrap.min.js
lrwxrwxrwx 1 tom tom   58 Dec 23 07:29 jquery.min.js -> /var/www/myproject/bower_components/jquery/dist/jquery.min.js
</code>```

However, I notice that these are stored within a directory /bower_components just as composer dependencies are stored in /vendor. So now I have /bower_components and /vendor as well as /node_modules (for grunt and grunt plugins). So as all Bower does it bring down the repositories, upon which I need to link to them - can I not just use composer for front end libraries too?

```<code>"components/jquery": "dev-master"
"components/bootstrap": "dev-master"
</code>```

.. then create symlinks to the files (e.g. .js .css) in my public/* directories? Is there any reason whhy Bower is still better for managing FE dependencies? Thanks

答: No Composer is a dependency manager for PHP only while Bower is optimized for front end dependencies that can be used with not only sites built with PHP but built with other programming languages and frameworks. I would stick with Bower for front end dependency management as that's what its designed for. :)</p>


答: ORM will only get you to some point. But there are cases when you have to execute a really complicated query, with complicated joins, subquery, unions, minus, analytical functions etc. That's when you need SQL. But how are you supposed to write complicated queries when you leave all simple queries to the ORM?</p>

Title: Is there still a need for writing SQL?

Body:
With so many ORM tools for most modern languages, is there still a use case for writing and executing SQL in a program, in a language/environment that supports them?  If so why?

For clarity: I'm not asking about if programmers need to know SQL, or if I should have a SQL tool on my desktop.  I'm asking specifically why I might have it in code (or config, or whatever) as opposed to an ORM.


问:
get All data vs get partial data Optimization
Let's say a client makes a GET call to the server to get all the  followers of some user. now the client shows a list of all the followers but the only data the list needs is:

```<code>{"username" : "user", "thumbUrl" : "http:/www.example.com/photo/1", "age" : 78}
</code>```

now the user can click on one of the followers and he can see more data about the follower he clicked.

My question: should i bring from advance all the followers data from the server (full User Object) vs bring only partial data and then make another call onDemand when the userclicks a follower. And more important is if do i really need to care about such optimizations?

assumptions:

data is throttled (10 Objects per call to followers)

size of each User Object is around 1kb, partial around 200 bytes

User usually clicks on 5 followers for each 10 Objects.

Points of Interest:

size saved: about 10kb - 2kb - 5kb = 3kb per bucket of 10 users. is it negligible at this age of the internet? would it matter if the size difference was 30kb?

bucket size: I gave examples with low bucket size but let's sat my bucket size can get up to 2Mb. Does it matter if my bucket size is 2Mb with the full User data vs 400kb with partial call? Is it slower? (Assuming the User will click enough followers to make the size difference negligible

Will welcome any other points of interest

答:
You can define the resources and representations in the way that suits your needs. I usually use GET to provide a "summary" view of a collection (like ".../followers") as a resource that provides a list of summaries of the followers, including their ids (or URIs if I'm being good). This is usually sufficient for the client to provide a list that the user can browse, and then drill down into.

However, sometimes the client really does want a list of the complete things. It just depends on your usage. And you can always provide a query string parameter (e.g. "?full=true") to switch back and forth (although an accept header, and content-negotiation, might be a more "correct" but complicated way to do it).

(As for the performance & optimization aspect, it's hard to pin down specific criterion, because that's going to be based on lots of things like your hardware, where it's deployed, middleware in front of your service, etc. Just (obviously) sending back fewer bytes will be faster... beyond that, you can do some performance testing to see what the acceptable thresholds are.)


答:
It depends.

Basically, you have to look at what the expected latency of the connection is, what the bandwidth is, and what responsiveness you want.

As an example: Suppose the round trip latency from client to server is 100 msecs and the bandwidth is 8 mb/s.  If you send the "full" data is 2Mb and the "partial" data is 400kb, then it will take 350 msecs to send the "full" record and 150 msecs to send a "partial" record.  If you send partial records, then each click requires 110 msecs to retrieve results.  Otherwise, each click is instant.  So:

Full - First load: 350 msec, click: instant

Partial - First load: 150 msecs, click: 110 msecs

The key point is to understand that each call adds overhead.  While it is very tempting to minimize the data transferred, this can actually make things slower, if it causes more round trips.

Of course, this is in and of itself misleading because network calls are variable.  But personally with these numbers I'd be tempted to load up front.

But this is just a very high level analysis.  Other things to consider:

This completely ignores the server side cost.  How fast does it take the "full" data vs. the "partial"?  Can you pull the "full" data, cache it for the future, and return the partial?

Code that gets the data in one block is likely to be simpler on both client and server, and therefore less buggy.

If you send partial data, you have to worry about what happens if records change between the first pull and the second.

To users, a single slow call followed by instant responsiveness feels "faster" than if every single click takes noticeable time.  You want to pay attention to how fast users feel the system is as much as possible at the expensive of concrete measures of how fast the system actually is.

In general, you are better off minimizing the number of network calls rather than minimizing the amount of data transferred overall.  But this cannot be a hard and fast rule because again, it really depends on both the expected bandwidth and the expected latency.  I should note, though, that bandwidth is constantly improving while latency is unlikely to improve significantly over time.

Title: get All data vs get partial data Optimization

Body:
Let's say a client makes a GET call to the server to get all the  followers of some user. now the client shows a list of all the followers but the only data the list needs is:

```<code>{"username" : "user", "thumbUrl" : "http:/www.example.com/photo/1", "age" : 78}
</code>```

now the user can click on one of the followers and he can see more data about the follower he clicked.

My question: should i bring from advance all the followers data from the server (full User Object) vs bring only partial data and then make another call onDemand when the userclicks a follower. And more important is if do i really need to care about such optimizations?

assumptions:

data is throttled (10 Objects per call to followers)

size of each User Object is around 1kb, partial around 200 bytes

User usually clicks on 5 followers for each 10 Objects.

Points of Interest:

size saved: about 10kb - 2kb - 5kb = 3kb per bucket of 10 users. is it negligible at this age of the internet? would it matter if the size difference was 30kb?

bucket size: I gave examples with low bucket size but let's sat my bucket size can get up to 2Mb. Does it matter if my bucket size is 2Mb with the full User data vs 400kb with partial call? Is it slower? (Assuming the User will click enough followers to make the size difference negligible

Will welcome any other points of interest


问:
Is a DLL developed in .NET is accessible from any language or operating system?
I am creating a DLL that I want to distribute to public to use it the way they want. This DLL contains common utility functions. People can use it on any operating system and with any language or framework. So, I want to ask that the DLL created using .NET 3.5 or above is accessible from other languages, operating systems or frameworks? Or do I need to write these functions in other language too or for different operating systems? I know only C# and I don't want to spend money for a free publicly distributed library.</p>

答:
A .NET DLL contains Intermediate Language which requires the .NET runtime to execute it and probably some .NET base libraries that it uses/depends on.

This means that the DLL can only be used on hardware/operating systems that have a matching .NET Framework available.

Writing code for all possible platforms is nearly impossible and I would advise you to figure out what platforms you really need to support because even when you find a way to run the DLL on all platforms it would cost a lot of effort to actually test it on all platforms and support it on all platforms. It will be a lot cheaper/easier to cover the key/main operating systems for your clients.


答:
A DLL is a format used for shared libraries by the Microsoft Windows operating system. Other operating systems use other formats, and since DLLs are binary they cannot generally be used on other processor architectures such as ARM devices. Therefore, DLLs are of no or little use under Mac OS X, on Linux-based operating systems such as Ubuntu, and on mobile devices (e.g. running iOS, Android, or Windows Phone).

(the point about processor architectures is not quite true since C# programs are typically compiled to intermediate bytecode that's architecture-independent. However, other DLLs don't have this flexibility)

Furthermore, code written in C# will typically require the .NET framework or at least the .NET runtime in order to work. Different Windows operating systems support different .NET  libraries. Code targeting the desktop might not work on mobile devices. Microsoft's .NET libraries are not currently available on non-Windows systems.

While your C#-written DLL will be of little use on non-Windows systems, there are a few possibilities to make your code more widely usable:

The WINE project offers a Windows compatibility layer for Unix-like operating systems. Provided that the processor architecture matches, this allows users to run EXEs, which may also use DLLs. However, WINE is not viable mechanism for making libraries usable. Unfortunately, the WINE project – as a volunteer effort – is lagging years behind in Windows features.

The Mono project offers a reimplemenation of the .NET framework and the C# language which runs on a variety of devices and operating system, including Linux and mobile devices. You could then recompile your library for each target system using Mono. However, the Mono implementation is lagging years behind, so you will not be able to use modern language features or newer additions to .NET APIs. Porting your code to Mono is possible, but may take some effort. Microsoft has announced that it will add support for non-Windows systems, but until then Mono is your best bet.

If you are content with only targeting Windows systems, offer compiled packages via NuGet. This makes it easy for other C# programmers to get and incorporate your library.

Consider publishing the source code. This makes debugging much easier for users of your library, and helps others help you. GitHub is a good place to start of you're using Git for version control.

Forget C#, and use a language that's really cross-platform. However, you'll always lock into a specific ecosystem. If you go with Java, your library can only be used from other languages running on the JVM (but the JVM runs on any operating system). Nearly any language can easily interface with a library written in C, but writing C is difficult (even more so if you want your code to be portable).

There may be more newer ways, but it's been a couple of years since I last wrote C#…

Title: Is a DLL developed in .NET is accessible from any language or operating system?

Body: I am creating a DLL that I want to distribute to public to use it the way they want. This DLL contains common utility functions. People can use it on any operating system and with any language or framework. So, I want to ask that the DLL created using .NET 3.5 or above is accessible from other languages, operating systems or frameworks? Or do I need to write these functions in other language too or for different operating systems? I know only C# and I don't want to spend money for a free publicly distributed library.</p>


问:
What is the (craziest, stupidest, silliest) thing a client/boss asked you to do?
See title, but I am asking from a technical perspective, not

Take my 40 year old virgin niece on a date or you're fired.

答: Ok, I want you to scan this picture of a house, when I come back, you should be able to show me the back portion of it.</p>


问:
What is the minimum cost graph inside a strongly connected component, which connects every vertex?
So for MST there are 2 possible definitions in an undirected graph. Keep in mind that in an undirected graph the MST algorithm always has n - 1 edges and no cycles.
In an undirected graph, it doesn't matter which definition you use, since both are correct, however inside a directed graph thats not the case anymore. Definitions:

Choosing a root vertex u in a graph, the MST is the smallest cost tree which connects every other vertex from u.

Given a graph, the minimal cost subgraph which connects all nodes is called a MST. (In an undirected graph this must be a tree)

In a directed graph the first definition for a directed graph is arborescence.
However the arborescence is different with every vertex you choose (This is not the case in an undirected graph), resulting in multiple possible directed MST variations. In the links section i have a video which explains the def. of an arborescence.

The second definition requires the directed graph to be one big strongly connected component. Hence it is now possible to go from any vertex u to any other vertex v, there is only 1 MST in a directed graph. However now we are not talking about trees anymore, hence the MST must include cycles.
In the links section i included a graph as example for the second definition.
In this image there are more then 1 possible minimum graphs, one for either of the red edges removed for example.

My question is, what is second definition called in a directed graph? (Does it have a special name like arborescence) and if so, isn't that the directed variant of MST? Is there an algorithm to compute the minimum graph inside a strongly connected component?

Definition of arborescence on Wikipedia

Quick video explaining what an arborescence is

I created a graph example of what i mean with the second definition:

答:
Alright so the problem is called MSSS and is NP-Complete,
i got pointed to the following stackoverflow discussion, which talks about this problem: https://stackoverflow.com/questions/1536067/minimum-cost-strongly-connected-digraph

However i still like the discussion about which of these problems:
MSSS vs Arborescence can be considered the inverse of MST.

So to answer my own question i have listed a few points for each of them (please comment if otherwise).

MST is a tree, only the Arborescence returns a tree. (+1 Arborescence)

MSSS only has one correct answer, as the MST does, it doesn't need any central points. (+1 MSSS)

Conclusion: Neither of these, MSSS or Arborescence can be called the directed version of MST, without talking about the other problem.


问:
Which tier in a webapp should create history records?
I have a 3-tiered web application with a web view layer, a business logic layer, and a database persistence layer. I am adding a feature that populates a history table with records if and only if the element being saved has changed (it compares the previous and current records and saves the history records if anything has changed).

I'm not sure if the logic of building the history records and saving them belongs in the business logic layer or the database persistence layer. The database persistence layer has a single saveElement method. The business logic layer has multiple places that call the database persistence's saveElement method.

Advantage of placing the history logic in the database persistence layer:

-If the logic were placed in the business logic layer, there is a risk that some of the business logic layer callers would forget to call the method to create the history records. If the logic was placed in the database persistence layer, any saved record is guaranteed to have a history record created.

-The site has another history system for other information that is in the database layer and it would create consistency if both systems were located in the same place.

Advantage of placing the history logic in the business logic layer:

-There is a bit of complexity in building the history records and the database layer is mainly used for calling/running sql queries.

So is there any compelling reason to place this logic in either the business logic layer or the database layer? Or does it not matter where the logic is placed?

答:
It depends.

Specifically, it depends on the logical level you would like to remember changes for. If "element changed" is a sensible history record, and you already have saveElement in the persistence layer, then extending saveElement to also log the change to a historical/archive record makes sense.

However, if you are trying to archive business-level events like "purchased inventory for project 4017" at a higher level than the elements you're storing, you will need to do that in the business layer, because that's where the intention of the activity is understood.

This is a classic layering issue: "where is the intention information available?" Often the straightforward answer (e.g. "we want to save history information and we already have a persistence layer, so that's where it should go!") is, if not incorrect, made dramatically less clear by higher layers decomposing their activities, and calling the persistence layer as more of a "save this!" workhorse. Higher level concepts are often unavailable by the time they filter down to persistence layers. At a minimum, then, you would need to adjust the API between the layers to allow the business layer to declare its intent (such as "for project X") as it calls saveElement.


问:
What is eventual consistency?
I've heard people talking about "eventual consistency" (for example in this question and this answer).

What is "eventual consistency"? How does it compare to "transactional consistency"? When does it happen?

What sort of impact does eventual consistency have on the design of systems which are affected by it? How can it be mitigated to provide a good user experience?

答:
What is "eventual consistency"? How does it compare to "transactional consistency"? When does it happen?

Consistency models describe how a system (nominally a distributed system) responds to change.

In an eventually-consistent system, all nodes will eventually have a consistent view of the overall system state. However, there will be a period of time after the initial change in which different nodes will have different views of the state.

In a transactionally-consistent system, the point at which all nodes have a consistent view of state is defined by applying transactional boundaries to the change. Either the transaction completes or it fails, and the thing that initiated the change will know which has happened. All nodes will see the same state both before and after the transaction completes.

Here's a real-world example: you go to your bank and deposit a check. You have initiated a change to two accounts: your account and the account of the person who wrote (issued) the check.

In a transactionally-consistent system, the addition of funds to your account happens at the same time as the removal of funds from the issuing account. At no point will the funds appear in both accounts (or in neither).

In an eventually-consistent system, the funds might be added to your account before they are debited from the issuing account. During some window of time, both accounts may show the added funds.

That latter scenario sounds very scary to most people. But it was exactly how the US financial system worked throughout the 20th century: you deposited a check, and that check was physically transported to the issuing bank, which then debited the money from the customer's account.

When you design your system to be eventually consistent, you need to be aware of problems that can arise from different nodes having different views of the world, and take steps to compensate. However, this compensation can lead you down a rat hole if you're not careful; it's easy to spend exorbitant amounts of effort to prepare for the case where the airliner carrying the not-yet-cleared checks crashes and burns.

On the other hand, with a transactionally-consistent system, you have to be ready for the failure of any node (or communications channel) to mean the failure of the entire system (or at least of every attempted transaction).

Title: What is eventual consistency?


答:
There is one very simple argument, which might at least amuse the management.

It is well known that the modern computers are not becoming "faster" like they used to be, because frequency scaling, for now, hit the limit. They increase their potential productivity by adding cores.

This implies that to benefit most from this architecture, the programs have to be parallellized. But parallel programming is way harder than sequential programming, due to a lot of new challenges it brings (consult Wiki article for comprehensive overview).

Functional programming helps to get rid of some of these challenges, e.g. race conditions don't apply if you only use immutable variables and methods without side effects. The learning curve for functional programming is often steep, but the learning curve for parallel programming might be even steeper, and not at all intuitive.

So if the challenge is to write more efficient programs in more efficient way, one can compare costs of training people to write parallel programs with costs of training people to learn functional programming, and the risks both approach might bring.

Regarding mixed languages (which support both functional and imperative programming style): from one point, they might be handy for the transition (people might start using them in the "familiar" way and gradually learn new approaches). From another point, this might be a blessing in disguise, because the potential advantages the functional programming brings might be cancelled with someone's clumsy code. One can mitigate this by establishing clear coding guidelines (see e.g. "Effective Scala" by Twitter), though following the guidelines requires a certain level of team maturity. From this point of view, pure functional languages might be "easier" for software development because of the stricter rules they impose by design.


问:
Version control for code that contains student exercises
I have a fairly substantial Python project that I have developed as an educational endeavor.  The version of the code that shall be given to students has exercises throughout, in the form of code that I have deleted and replaced with an exception.  To be specific:

```<code>    def mk_eq_term(i):
        # raise ExerciseError("BitBlaster::bitblast_EQ_Core")
        return PL.And(val,PL.Iff(le.bits[i],re.bits[i]))
</code>```

The last line is the real code; the second line is what shall be in the code given to students, once un-commented.  I am not an expert on version control (in fact, at present, I do not use revision control), but my reading on the subject indicates that this use case is suboptimal.  It seems like I will have to maintain two separate branches, and that any change I make against the "production" version will need to be reconciled against the "educational" version, even though I do not expect or intend to make changes to the codebase that will modify the exercise solutions.

What is the best solution for maintaining something like this?

答:
Version control really is the wrong tool for this. (Of course, you should still be using version control for your code!)

You don't have separate but inter-related lines of development for your code. Instead, what you have is two completely different pieces of code.

However, those different pieces of code are related in such a way that one can be (semi-)automatically derived from the other. So, that's what you should do.

Use some kind of templating or preprocessing language or text manipulation tools (sed, awk, the C preprocessor, T4, …) to generate the student version from the master version.

This can be as simple as using the C preprocessor something like this:

```<code>def mk_eq_term(i):
#ifdef STUDENT
    raise ExerciseError("BitBlaster::bitblast_EQ_Core")
#else
    return PL.And(val,PL.Iff(le.bits[i],re.bits[i]))
#endif
</code>```

You could also use Python's ast module to manipulate the Abstract Syntax Tree for the code and something like the Meta library to write it back out again:

Say, you had written your function in the following way:

```<code>def mk_eq_term(i):
    """BitBlaster::bitblast_EQ_Core"""

    return PL.And(val,PL.Iff(le.bits[i],re.bits[i]))
</code>```

Then you could use the following script to transform all functions into their student versions like so:

```<code>from ast import *
class RewriteFunctions(NodeTransformer):
    def visit_FunctionDef(self, node):
        exception = get_docstring(node)
        if not exception: return node
        node.body = [Raise(Call(Name('ExerciseError', Load()), [Str(exception)], [], None, None), None, None)]
        return node

tree = parse(code) # assuming code contains the Python code to rewrite
RewriteFunctions().visit(tree)
fix_missing_locations(tree)
</code>```

At this point, you have an AST with all functions that have docstrings modified so that the only statement in their body raises an exception whose name is the content of the docstring.

Of course, you will still have to unparse the AST into Python source, there are various third-party libraries to do that.

Body:
Version control really is the wrong tool for this. (Of course, you should still be using version control for your code!)

You don't have separate but inter-related lines of development for your code. Instead, what you have is two completely different pieces of code.

However, those different pieces of code are related in such a way that one can be (semi-)automatically derived from the other. So, that's what you should do.

Use some kind of templating or preprocessing language or text manipulation tools (sed, awk, the C preprocessor, T4, …) to generate the student version from the master version.

This can be as simple as using the C preprocessor something like this:

def mk_eq_term(i):
#ifdef STUDENT
    raise ExerciseError("BitBlaster::bitblast_EQ_Core")
#else
    return PL.And(val,PL.Iff(le.bits[i],re.bits[i]))
#endif

You could also use Python's ast module to manipulate the Abstract Syntax Tree for the code and something like the Meta library to write it back out again:

Say, you had written your function in the following way:

def mk_eq_term(i):
    """BitBlaster::bitblast_EQ_Core"""

    return PL.And(val,PL.Iff(le.bits[i],re.bits[i]))

Then you could use the following script to transform all functions into their student versions like so:

from ast import *
class RewriteFunctions(NodeTransformer):
    def visit_FunctionDef(self, node):
        exception = get_docstring(node)
        if not exception: return node
        node.body = [Raise(Call(Name('ExerciseError', Load()), [Str(exception)], [], None, None), None, None)]
        return node

tree = parse(code) # assuming code contains the Python code to rewrite
RewriteFunctions().visit(tree)
fix_missing_locations(tree)

At this point, you have an AST with all functions that have docstrings modified so that the only statement in their body raises an exception whose name is the content of the docstring.

Of course, you will still have to unparse the AST into Python source, there are various third-party libraries to do that.


问:
Where are all the functional programming design patterns?
OO programming literature is full of design patterns. Most books on object oriented programming dedicate a chapter or two to design patterns like factories and decorators. So what are the equivalent patterns in functional languages and why hasn't anyone written a book about them yet? Is there something special about functional languages that obviates the need for design patterns?</p>

答:
A good talk (~45 min) on this topic by Stuart Sierra:

http://www.infoq.com/presentations/Clojure-Design-Patterns

Not necessarily binding and authoritative, but I recognized a number of his examples from my own experience using FP for data analysis.

Examples written in Clojure, but likely applicable to any FP language.  The names he gives to the patterns he covers are:

State/Event

Consequences

Accumulator

Reduce/Combine

Recursive Expansion

Pipeline

Wrapper

Token

Observer

Strategy


问:
The reason for scala not supporting Multiple Inheritance
I've searched around for a long time now and haven't come up with any official reason why scala doesn't support multiple inheritance. I know traits solve a lot of things, but the developers of C# for example give an explicit reason why not to implement it (link here).

Any pointers?

答:
Scala does support Multiple Inheritance: you can inherit from as many traits as you want.

So, the reason for why there is no official documentation for the reasons for not supporting MI is simply that there aren't any, because Scala does support MI. You say "traits solve a lot of things", and MI is one of them.

ContentLicense: CC BY-SA 4.0


问:
Why is it that MS Data Access story is so fractured ? Is it the nature of Data Access or is just MS?
This StackOverflow question asks "where can I get Microsoft.Data.Objects"

It turns out the answer was probably that its in the CTP4 (code first) release of Entity Framework 4
However there where a lot of guesses.  Including

System.Data

Entity Framework

Microsoft.ApplicationBlocks.Data

Microsoft.Practices.EnterpriseLibrary.Data

10 years ago if someone asked a similar question for they might have gotten DAO, RDO, ADO.

Is this just the nature of the beast or is it MS.

Does this pattern happen with other vendors? Where the base data access strategy is either wrapped or changed?

答:
This is the very nature of IT!  Things CHANGE!  In the Java world, they had the same thing...
JDBC, EJB 1.0, EJB 2.0, Hibernate, EJB 3.0 and so on.  </p>


答:
Nearly every major programming language has a library to handle the directory separators for you. You should leverage them. This will simplify your code and prevent bugs.

In my experience, the usual reason for combining strings like this is that they come from different sources. Sometimes it's different pieces from a configuration file. Sometimes it's a constant combining with a function argument. In any and all cases, when they come from different sources, you have to consider several different possible cases regarding the separators on the ends to be combined:

Both ends could have a separator: "images/" and "/sounds"

Only one has a separator: "images" and "/sounds" or "images/" and "sounds"

Neither has a separator: "images" and "sounds"

The fact each part comes from a different source means each source might have its own ideas about what conventions to follow, if someone gave any thought to it at all! Whatever is calling your code should not have to worry about this. Your code should handle all cases because someone will violate your convention. This will result in wasted time investigating the cause of an error and making a fix. I have had several unpleasant occasions where a coworker made an assumption about how paths should be formatted in a configuration file, meaning I had to go hunt down the code and figure out what they were expecting (or fix the code).

Most major languages provide a method to do this for you that already handles many of the cases:

os.path.join for Python

File.join for Ruby

Path.join for Node.js

Paths.get for Java (7 and up)

Path.Combine for .NET

filesystem::path.operator+ for C++17

There is a caveat with these. A number of these seem to assume that a leading directory separator in the second argument refers to a root path and that this means the first argument should be dropped entirely. I don't know why this is considered useful; for me, it just causes problems. I've never wanted to combine two path portions and end up with the first part being dropped. Read the documentation carefully for special cases, and if necessary, write a wrapper that does what you want with these instead of their special handling.

This additionally helps if you have any need for supporting different operating systems. These classes almost ubiquitously account for choosing the correct separator. The libraries usually have a way of normalizing paths to fit the OS conventions, as well.

In the event that your programming language does not have a readily available library, you should write a method that handles all these cases and use it liberally and across projects.

This falls into the category of "don't make assumptions" and "use tools that help you."

Title: Is there a conventional way to combine file path strings?

Body:
In an example:

```<code>var assets = "images/"

var sounds = assets+"sounds/"
</code>```

Is it more conventional to put the slash on the back of a file path?

```<code>var assets = "/images"

var sounds = assets+"/sounds"
</code>```

Is there another method that is a good common practice?


问:
What does "business logic" actually mean if not "all non-3rd party code"?
I've heard people talk about business logic a lot at work, and online, and I've read several questions on this site about it, but the term still doesn't make a lot of sense to me. For example, here are some (paraphrased) statements I often see:

"The business logic is the part of your program that encodes the actual business rules." Most of the definitions I've read are circular ones like this.

"Business logic is everything unique to your particular application."  I don't see how this is different from "your particular application is nothing but business logic", unless we accidentally reinvented a bunch of wheels we could have used existing 3rd party software for. Hence the question title.

"There should be a Business Logic Layer above your Data Access Layer and below your GUI Layer." In the code I write, the database accessors have to know what data they're supposed to be accessing, and the UI code has to know a lot about what it's displaying in order to display it correctly, and there's nothing to really do in between those two places other than passing blobs of data between client and server. So what's actually supposed to go into a Business Logic Layer?

"Business logic should be separate from presentation logic." Most of the feature requests we get are to change the presentation logic for business reasons. If one of the business rules is to display US government bond prices in 32nds notation by default (while also providing a UI for the user to configure that), the presentation logic needs to at least know this rule exists, if not fully implement it. Also, it seems like a major part of UX design is helping the user understand the business rules our software is trying to implement.

Is it possible that I actually am on a team that only does business logic, and all the non-business logic is being done by other teams? Or is the whole concept of "business logic" as a separate entity only workable for certain applications or architectures?

To help make the answers concrete: Pretend you have to reimplement the Domino's Pizza app. What is the business logic, and what is the non-business logic of that app? And how would it be possible to put that pizza-ordering business logic in its own "layer" of code, without most of the pizza information bleeding into the data access and presentation layers?

Update: I've come to the conclusion that my team is probably doing 90% UI code and most--but not all--of what you'd call business logic comes from other teams or companies. Basically, our application is for monitoring financial data, and almost all of the features are ways for the user to customize what data they see and how they see it. There is no buying or selling going on (though we integrate a bit with other apps from our company that do that), and the actual data is supplied by loads of external sources. But we do allow users to do things like send copies of their "monitors" to other users, so the details of how we handle that probably qualify as business logic. There actually is a mobile app that currently talks to some of our backend code, and I know exactly what portion of our frontend code I would like it to share with our UI in an ideal world (basically the M in our quasi-MVC) so I'm guessing that's the BLL for us.

I'm accepting user61852's answer since it gave me a much more concrete understanding of what "business logic" does and doesn't refer to.

答:
It sounds like most of your work may be in the UI layer.  Changing the display format for business reasons, does not imply any business logic.  The change is a change to the view logic.

Being able to change the format implies some business logic possibly involving persistence of the preference.

Persisting the format to a cookie, could also be implemented in the view layer.

However, this could be implemented in a MVC manner.  (Some models implement the view as its own MVC capable of dealing with preferences.)

The user's preference could be stored by the model (database/cookie).

The controller would react to format requests by changing the user's preference in the model.

The view would adjust to the user's preference.  The preference can be requested from the model, or provided by the controller.

Making an educated guess about your application.

There is a model containing available bonds, and pricing data for them.

There is a view allowing the user to see various things they can do: search for bonds, display prices, comparing yields, taking orders, and which displays the results returned by the business model in response to the request.

The business logic handles things like:

Performing a search and providing for the view to display.

Finding prices for a bond and providing for the view to display.

Comparing yields and providing data for the view to display.

Processing orders and storing them in the model.

If this is done right, it should be possible to provide multiple view components without changing the model or business logic.  For example, if the current design is a web site, a new view server for an iPhone or Android application would use the existing model and business logic.  These may introduce new business functionality to provide push notifications when an order is fulfilled, which may require changes to multiple layers.

This breakdown allows separation of concerns.

The data layer represented by the model tends to be relatively stable.

The business layer is where business decisions are applied: Will/can the request be fulfilled?  Has all the required data been obtained?  Is the user authorized?  Are there any red flags on the transaction?

The view layer tends to be less stable, and there may be more than one.  This is where the look and feel of the application resides.  It is possible to completely re-skin an application, without changing the other layers.


答:
You're coming at this from the wrong direction.

You're trying to convince management of a switch to a functional paradigm for your own amusement and you're trying to rake in arguments to support this that have got nothing to do with the real reason why you want it. Otherwise you wouldn't need to ask the question, because you'd be able to list your arguments from the top of your head.

Rather, what you should be thinking about is what the current business need is and how it is best served. If it so happens that it is best served using a functional paradigm then - yay! - you get to play. But if you do a fair analysis, taking into account operational business needs, necessary training of co-workers, backgrounds of future programmers, maintenance, and so on and so forth, often it won't be.


答:
In my (somewhat cynical) experience, having worked for a shop where we did use functional programming, and interviewed at several others:

There was always a CTO and other high-level technical people who had experience with functional programming and managed to convince the non-technical executives of it.  (And incidentally, these folks are better qualified to answer your question than I am.)

Once these folks leave the company, and get replaced by folks who don't have this inclination, things will go south.  The new guys will blame everything that goes wrong (including, and particularly their own failings) on the weird programming language and paradigm used to build what came before.  They will marginalize the remaining folks with functional programming skills, pushing them out of the company.  The system built on the functional language will deteriorate unmaintained.  This sort of thing, in my mind, the biggest risk that a business takes on if they adopt a functional language, and must not be underestimated.

The organization has to have a "build instead of buy" culture for this to work.  Because adopting a functional language will mean fewer "buy" options.

There was almost always some compromise to the technical and non-technical detractors of the idea.  The most common of these compromises is that any non-JVM language was just out of consideration; Clojure and Scala were proposed, Haskell and O'Caml were just out right off the bat.


问:
What is the use-case to use C++ friend class?
I am trying to understand C++ friend. When is the good use case to use friend? I suppose if we want to let another class have access to another classes attributes, why don't we just make it as public or inherit from that class instead?

Thank you for your help.

答:
I've found friend classes in C++ to be useful where in Java I would have used package access. That is, I have a bunch of classes that are so intimately related that they are written and maintained as a unit, in the same source file(s). Anyone working on one of them is really working on all of them. The invariants that they maintain they maintain together. It makes sense for them to see each other's internals so they can maintain their shared invariant.

What doesn't make sense is protected access. If it's not safe to expose some part of my internals to the public, it's not safe to expose it to whatever jackanapes comes along later in a completely unrelated project and claims to be my subclass. Let subclasses use my public interface, just like everyone else. (Unless they're friends, but in that case I wrote them and implemented them in the same source, so they're hardly from some other project.)


答:
I'll give you some tips regarding CRUD applications, since I don't have much experience in games or graphically intensive apps:

Business logic usually involves rules the owner of the business has learned or decided over years of operation, like for example: "reject any new credit if the client hasn't yet finished paying the last one", or "we don't sell breakfast past 11 am", or "mondays and tuesdays, customers can buy two pizzas for the price of one".

Of course the presentation layer must show a message indicating the availability of a discount, or the reason of a credit being rejected, but such layer is not deciding those things, it's only communicating to the user something that happened under the hood.

Business logic usually involves a workflow, for example: "this item must be aproved within 3 working days by some manager or put into a 'request for information' stage, if customer hasn't submitted the required documents, then the item is rejected".

Presentation layer usually doesn't deal with that kind of workflow, it only reflects the states of the workflow.

Also, data access layer is usually straightforward, because decisions have already being made by the business logic. This layer is affected when you decide to migrate your data from MS SQL Server to Oracle, for example

It's true sometimes GUI does some validation to avoid calls to the server, but that is something that should be done judiciously or you could have a lot of business logic in that layer.

Much of your confusion may have arisen from the fact that in your application there's no separation of concerns and effectively you have too much business logic in the presentation layer. The fact that you (wrongly) have business logic in your presentation layer or data access layer doesn't change the fact that it's business logic nonetheless.

Things like displaying distances in the metric system instead of miles/yards/feet is not presentation logic, it's business logic. The business layer has to return data in the required units and tell the presentation layer what units it's handling for it to show the appropiate labels, but it's definitely a business logic concern.

Business logic shouldn't be affected by the fact that you are using Oracle now instead of Postgres, or by the fact the company changed it's logo or style sheet.

Business rules exist whether or not you automate them by writing an app. They can be enforced even when the business uses a low tech solution like pen and paper.

If you have a mobile version of your desktop app, or a web version, each one of those versions have a different presentation layer, but (hopefully) the same business layer.

Title: What does "business logic" actually mean if not "all non-3rd party code"?

Body:
I've heard people talk about business logic a lot at work, and online, and I've read several questions on this site about it, but the term still doesn't make a lot of sense to me. For example, here are some (paraphrased) statements I often see:

"The business logic is the part of your program that encodes the actual business rules." Most of the definitions I've read are circular ones like this.

"Business logic is everything unique to your particular application."  I don't see how this is different from "your particular application is nothing but business logic", unless we accidentally reinvented a bunch of wheels we could have used existing 3rd party software for. Hence the question title.

"There should be a Business Logic Layer above your Data Access Layer and below your GUI Layer." In the code I write, the database accessors have to know what data they're supposed to be accessing, and the UI code has to know a lot about what it's displaying in order to display it correctly, and there's nothing to really do in between those two places other than passing blobs of data between client and server. So what's actually supposed to go into a Business Logic Layer?

"Business logic should be separate from presentation logic." Most of the feature requests we get are to change the presentation logic for business reasons. If one of the business rules is to display US government bond prices in 32nds notation by default (while also providing a UI for the user to configure that), the presentation logic needs to at least know this rule exists, if not fully implement it. Also, it seems like a major part of UX design is helping the user understand the business rules our software is trying to implement.

Is it possible that I actually am on a team that only does business logic, and all the non-business logic is being done by other teams? Or is the whole concept of "business logic" as a separate entity only workable for certain applications or architectures?

To help make the answers concrete: Pretend you have to reimplement the Domino's Pizza app. What is the business logic, and what is the non-business logic of that app? And how would it be possible to put that pizza-ordering business logic in its own "layer" of code, without most of the pizza information bleeding into the data access and presentation layers?

Update: I've come to the conclusion that my team is probably doing 90% UI code and most--but not all--of what you'd call business logic comes from other teams or companies. Basically, our application is for monitoring financial data, and almost all of the features are ways for the user to customize what data they see and how they see it. There is no buying or selling going on (though we integrate a bit with other apps from our company that do that), and the actual data is supplied by loads of external sources. But we do allow users to do things like send copies of their "monitors" to other users, so the details of how we handle that probably qualify as business logic. There actually is a mobile app that currently talks to some of our backend code, and I know exactly what portion of our frontend code I would like it to share with our UI in an ideal world (basically the M in our quasi-MVC) so I'm guessing that's the BLL for us.

I'm accepting user61852's answer since it gave me a much more concrete understanding of what "business logic" does and doesn't refer to.


问:
Why might it be difficult to make a 64 bit version of a program?
In my short time programming, it has been trivial to compile any of my C++, Java, etc. for either a 32 or 64 bit machine so long as I have the full source for the program.

But a lot of software is not released 64bit.
Most annoyingly, there isn't yet a 64bit release of the Unity engine.

What makes it difficult to compile some programs for 64 bit machines?

答:
The general problem is that it’s very easy to encode undocumented assumptions in a program, and very hard to find places where those assumptions were made. High-level languages tend to insulate us from these concerns somewhat, but in lower-level languages used for implementing platforms and services, it’s easy to do things that are not necessarily portable across architectures:

Assuming that int is large enough to store a pointer

Assuming properties of the representation of pointers, e.g., for pointer tagging

Assuming that data pointers and code pointers have the same size

There is also the practical concern of release management. If I only make an x86 build, it will still run on x86-64, albeit perhaps more slowly due to the limited availability of registers. Whereas if I build for both x86 and x86-64, I must now test on both architectures and deal with bugs that may only arise on one architecture, increasing the cost of shipping a new release.


答:
Most software will work the same when compiled for both the 32 and 64 bit Intel/AMD architectures. However, some software will not. Aside from laziness, or reaching a larger audience, there are some specific reasons why recompiling as 64 bit will not work.

Software may use unsafe pointer operations. Perhaps a program puts a pointer into an int, which is generally 32 bit for most C and C++ compilers. Pointers are 64 bits in a 64 bit program. That does not work.

Bit shift operations may produce different results if the integer type being used is a different size. This may be an issue when using a regular data type instead of a standard typedef such as int32_t

A data type used in a union may change sizes, changing the behavior of the union.

Software may rely on libraries that are 32-bit only. In general, a 64 bit program will only work with 64 bit libraries due to assumptions about the stack, pointers, etc.

The difficulty you ask about in your question is simply that in some code bases there may be millions of lines of code that perform unsafe operations, make unsafe assumptions, have shortcuts and clever "optimizations" put in by developers. The code will either not compile in a 64 bit environment, or it will compile but have show-stopper bugs. It may take a long time to fix all the issues. Maybe a company will fix them over time until it is possible to release a 64 bit version. Maybe a company will develop a "version 2" alongside current maintenance releases because a total rewrite is necessary.

The moral of the story is to write clean code and do not try to second-guess the compiler or add clever optimizations that are not needed, can break the software, and probably do not help anyway.

This article goes into far more detail than I could hope to include in this answer: 20 issues of porting C++ code on the 64-bit platform

Title: Why might it be difficult to make a 64 bit version of a program?

Body:
In my short time programming, it has been trivial to compile any of my C++, Java, etc. for either a 32 or 64 bit machine so long as I have the full source for the program.

But a lot of software is not released 64bit.
Most annoyingly, there isn't yet a 64bit release of the Unity engine.

What makes it difficult to compile some programs for 64 bit machines?


问:
How do I create a modal service with AngularJS?
I'm trying to make a service that's polymorphic based upon what mode is specified in the URL. If the char param in the route is set to 'p', I want to use a PresentMode service. If the char param is set to 'n', I want to use a NoteMode service. Each of these present the same interface, but I want to choose one at a time.

So far the best solution I've come up with is something like this:

```<code>var mod = angular.module('modeModule', []);

mod.service('modeService', function($routeParams, presentMode, noteMode) {
  if ($routeParams.char === 'p') {
    this.mode = presentMode;
  } else if ($routeParams.char === 'n') {
    this.mode = noteMode;
  }
}

mod.service('presentMode', function() {});
mod.service('noteMode', function() {});
</code>```

This works, but it requires that I append .mode to the end of every access (eg modeService.mode.blah(). Is there a better way to do this?

答:
I don't understand what you'd like to have happen. You'll get a lot more traction on this question on the regular stackoverflow.

There's a lot of different styles to go about this. Personally, I keep my services clear of logic and just use them to wrangle data and as a central api. in my controllers, those data and api methods get scoped to the view. When I need to do some logic on the data or method, I'll use an angular decorator or filter.

To sum up my way,
Services - data and methods
Controllers - $scopes and $watchers (this is where you can set $scope.exMethod = exService.exMethod() and then just call exMethod() in your html)
Filters / Decorators - business logic (put your if logics here)


答:
I don't think arguments or facts will help. And certainly not without stating the problems you want to solve.

Against common believe and typical self evaluation many decisions are made based on gut feeling. And often these decisions are very good decisions, because they incorporate on a subconscious level a lot of experience of the individual making the decision.

If you  want to challenge such a decision like "We'll stick to C like language until the end of all computers" you have to do more than just provide some arguments.

The first step is probably to uncover the persons and reasons behind the decision that senior management should have a saying in such technical decisions. Of course I can only guess here, but very likely they have quite a track record of decisions made by technical personal gone bad. Let's face it: Most developers aren't very good at making (even technical) decisions on a company level.

Once you found these people talk to them in order to gain there trust. Possibly the best approach is: listen to them. What are they concerned about, what are the risk and chances they see. What are problems they are challenged with. From here you might move to get technology people involved into this kind of decision. Management often doesn't really want to make these decisions, but doesn't trust others with it. So if you team starts to get involved into architectural decision and demonstrate that the decisions you propose are sound management might be willing to trust you/your team.

Important in order to come up with sound architectural decisions is:

Gather input from stake holders (Management, Users, Administrators, Sales, Clients ...)

Base decisions on that input

Communicate clearly: What the (proposed) decisions are; What risk they aim to mitigate; What conflicting interests are and with some delay: how well they worked.

If you work for a large company with say 10K+ employees, be prepared to learn some of the following lessons.

speed of coding isn't really relevant for the bottom line.

things like maintainability on the scale of decades is.

the problems you think you can solve using functional languages aren't really relevant for the bottom line

problems like training 1000 developers, the natural resistance to change and maintaining a code base written by developers with less than 5years experience in the technology used are.

Once you reached a level of trust that your arguments are heard and considered you will also have established a way of gathering and considering requirements that you, your team and management trusts.

If this process produces the recommendation to use a functional approach in certain areas you are done.

If this process produces the recommendation to ignore functional approaches going beyond what the current main programming language offers you are done as well.

The bad news is: Depending on the size and style of the company this might easily take a couple of years or decades.

The good news is: You will learn a lot on the way.

Since the first step is to start to talk and especially listen to senior management I'd recommend starting with reading Just Listen.


问:
Does it make sense to have a separate init function?
I'm created an opaque type and I have two options for its management.

The first looks like this:

```<code>type_t *a = type_init();
int err;

err = type_do(a, "foo", "bar", FLAGBIT1|FLAGBIT2, NULL);
if (!err) {
    type_print_result(a);
    ...
}

type_free(a);
</code>```

The second is:

```<code>type_t *a;
int err;

err = type_do(&a, "foo", "bar", FLAGBIT1|FLAGBIT2, NULL);
if (!err) {
    type_print_result(a);
    ...
}

type_free(a);
</code>```

type_do is the function that calculates the results we could work on. As you may underastand in the second case the initialization happens within type_do, that's why I have to pass the address of a. It is absolutely necessary to call type_do before doing anything else with type_t. Is there any reason to have a separate init function?

答:
Yes, it makes sense to have a separate init function.

The first case is great: define a variable and initialize in 1 step.  Easy to use paradigm.

In the 2nd case, if used, the code should be tolerant of initialization with 0 and/or NULL and acceptable to a subsequent type_free().  Rational: that what users will do as there is so much blanketed initialization with functions like memset(p,0,size) and calloc(), etc and count on that as acceptable coding.  Why build a type_free() that doesn't cope well with 0?

```<code>type_t *a;
err = type_do(&a, "foo", "bar", FLAGBIT1|FLAGBIT2, NULL);
type_free(a);
...
type_t *b = 0;
type_free(b);
</code>```

I would even advocate a tolerant type_free(0); in the first case too.

Body:
Yes, it makes sense to have a separate init function.

The first case is great: define a variable and initialize in 1 step.  Easy to use paradigm.

In the 2nd case, if used, the code should be tolerant of initialization with 0 and/or NULL and acceptable to a subsequent type_free().  Rational: that what users will do as there is so much blanketed initialization with functions like memset(p,0,size) and calloc(), etc and count on that as acceptable coding.  Why build a type_free() that doesn't cope well with 0?

type_t *a;
err = type_do(&a, "foo", "bar", FLAGBIT1|FLAGBIT2, NULL);
type_free(a);
...
type_t *b = 0;
type_free(b);

I would even advocate a tolerant type_free(0); in the first case too.


答:
I see two reasons why a separate initializiation makes sense. First, there is the the "Single Level of Abstraction" principle, which helps to make code more readable and more evolvable. This means, if type_init and type_free are a pair of associated functions, it makes perfectly sense to call them at the same level whenever possible.

The second reason is that in case initialization fails, you might be able to catch that within the function above, so your code should probably look like this:

```<code>type_t *a = type_init();
int err;

if(!a) {
    // signal to the caller that initialization failed
    return;
}

err = type_do(a, "foo", "bar", FLAGBIT1|FLAGBIT2, NULL);
if (!err) {
    type_print_result(a);
        ...
}
else {
    // signal to the caller that type_do failed
}
type_free(a);
</code>```

(nevertheless, type_free should still behave well when it gets a 0 passed, of course).

Title: Does it make sense to have a separate init function?

Body:
I'm created an opaque type and I have two options for its management.

The first looks like this:

```<code>type_t *a = type_init();
int err;

err = type_do(a, "foo", "bar", FLAGBIT1|FLAGBIT2, NULL);
if (!err) {
    type_print_result(a);
    ...
}

type_free(a);
</code>```

The second is:

```<code>type_t *a;
int err;

err = type_do(&a, "foo", "bar", FLAGBIT1|FLAGBIT2, NULL);
if (!err) {
    type_print_result(a);
    ...
}

type_free(a);
</code>```

type_do is the function that calculates the results we could work on. As you may underastand in the second case the initialization happens within type_do, that's why I have to pass the address of a. It is absolutely necessary to call type_do before doing anything else with type_t. Is there any reason to have a separate init function?

Body:
I see two reasons why a separate initializiation makes sense. First, there is the the "Single Level of Abstraction" principle, which helps to make code more readable and more evolvable. This means, if type_init and type_free are a pair of associated functions, it makes perfectly sense to call them at the same level whenever possible.

The second reason is that in case initialization fails, you might be able to catch that within the function above, so your code should probably look like this:

type_t *a = type_init();
int err;

if(!a) {
    // signal to the caller that initialization failed
    return;
}

err = type_do(a, "foo", "bar", FLAGBIT1|FLAGBIT2, NULL);
if (!err) {
    type_print_result(a);
        ...
}
else {
    // signal to the caller that type_do failed
}
type_free(a);

(nevertheless, type_free should still behave well when it gets a 0 passed, of course).


答: One of Scala's primary design goals is to interoperate with Java as smoothly as possible. In order to achieve this, a Scala class must have a one-to-one correspondence with a JVM class. Because the JVM ddoesn't support multiple inheritance, it would therefore be impossible for Scala to do so without introducing massive hacks.</p>

Title: The reason for scala not supporting Multiple Inheritance

Body:
I've searched around for a long time now and haven't come up with any official reason why scala doesn't support multiple inheritance. I know traits solve a lot of things, but the developers of C# for example give an explicit reason why not to implement it (link here).

Any pointers?


问:
Can BDD and Lean methodologies be used together?
I was chatting with my product manager last week and he was bemoaning the lack of progress on our product.  It's a fair criticism, too.  So we got to talking about to describe the writing of requirements.  I'm a big fan of BDD and using something like the Gherkin syntax to describe how the system should behave in terms of a user or actor.

He was pretty dismissive of BDD and said we should be using Lean methodologies like SBCE (set based concurrent engineering) and other stuff which I don't know a massive amount about given I've not read much on Lean practices so far.

Are these two methodologies mutually exclusive? If not BDD then there would need to be some other way of describing what the system should do.  Does Lean have its own language for requirements?

答:
Most of our Lean knowledge comes from the work that Deming did at Toyota. There are two main ways in which I look at Lean:

Lean Product Development

Lean Production.

Lean Product Development is the equivalent to designing new cars, and is more like software development than production is. We're busy creating new things, not producing the same old thing again and again predictably. It's about minimizing work in progress, getting fast feedback and using those metrics to work out what to build.

Lean Production is more like a factory. The idea is to minimize variability to ensure high-quality. The only bit of software that's even vaguely like this is the build system, but even that's more like designing the factory along with the car. Particularly, Lean Six Sigma is about reducing the variability enormously, and is completely, totally inappropriate for SW dev.

The one thing they do both have in common is that minimization of work in progress. (It's a bit more complicated than this, but this is a light overview for you.)

I would be very careful, when looking at "Lean", regarding which of the techniques you apply. Fortunately SBCE is from the first, not the second, so your boss is mostly on the right page. Lean Start-Up approaches (which is where I'm guessing he read about SBCE) are also part of that group.

Lean and BDD are completely compatible; in fact, I recommend a Kanban System approach with BDD anyway. In shorthand, this translates to reducing the gap between the conversations around scenarios happening, and the actual work on those scenarios being done, while minimising the number of conversations which aren't being progressed to software (because you'll forget what you talked about over time).

SBCE is a method for running multiple concurrent experiments, which is useful when there's uncertainty around the work that needs to be done. BDD is really great at helping to work out which bits of work are uncertain, and which are well-understood or require expertise. The Specification-By-Example bit of BDD is only one part of BDD, though it's the part most people are familiar with, and that's probably why your boss is dismissing it (unnecessarily).

For more info, try this blog I wrote on using BDD as a sensemaking technique (finding those borders I just talked about), this one on estimating complexity, or watch any of my talks on BDD and Cynefin. Your boss may find the first blog I've linked reassuring as well.