问:
which pattern is most intuitive for a calculator app?
The title says it all. I'm trying to build a calculator application (for self-learning purposes). The application is going to have a very common UI, with plus(+), minus(-), multiply(*) and a divide(/) button. Also, the app can do, real-number as well as complex-number calculations.

So, the situation here is, depending upon the mode(normal or complex), the same button should perform different calculation ? Which pattern should I be using for this situation ? I feel, strategy pattern should be a good fit, but then, I don't exactly know how to implement that - I mean, I'm just not sure about how to design my classes, what to have as Interfaces, and what as delegates.

CURRENTLY, MY DESIGN CONTAINS

```<code>IOperation
{
  Do();
}
Add:IOperation{}
Subtract:IOperation{}
Multiply:IOperation{}
Divide:IOperation{}
Root:IOperation{} //not supported by ComplexNumber
ISupportedOperation
{
   IList<IOperation> SupportedOps {get;}
}
INumber : ISupportedOperation {}
RealNumber:INumber{}
ComplexNumber : INumber {}
</code>```

Interface names starts with I

All others are concrete classes

BUT IT'S A MESS. And, I'm totally lost within my own classes, and interfaces.

PS: Of course, I can do this using if/else, but that's not what I want to do. Not because I forcefully want to use a pattern, but because, those if-else will be scattered everywhere in the program for eg. ReadInput, PlusButtonClick, MinusButtonClick, etc. And, as I understand, design patterns are supposed to avoid these kind of situations of code-repetitions, by clever/tricky re-organization of the existing code.

PPS: Sorry for being too verbose.

答:
First of all, a simplification: all real numbers are a subset of complex numbers, so just do everything with complex numbers.

Secondly, why isn't Root supported by ComplexNumber?  If you're supporting complex numbers, then you can take the root of any number, including negative or complex ones.  It all just becomes vector multiplication.  So if it's all complex numbers, then you don't need to have ISupportedOperation, since every operation is supported (short of divide by zero, of course, but we usually handle that by throwing an exception).

Really, this should do:

```<code>interface ICalculator
{
    IComplexNumber Add(IComplexNumber a, IComplexNumber b);
    IComplexNumber Subtract(IComplexNumber a, IComplexNumber b);
    IComplexNumber Multiply(IComplexNumber a, IComplexNumber b);
    IComplexNumber Divide(IComplexNumber a, IComplexNumber b);
    IComplexNumber Root(IComplexNumber a, IComplexNumber b);
}
</code>```

Remember, too, that a square root is just a^(1/2), so a more generic interface would be:

```<code>interface ICalculator
{
    IComplexNumber Add(IComplexNumber a, IComplexNumber b);
    IComplexNumber Subtract(IComplexNumber a, IComplexNumber b);
    IComplexNumber Multiply(IComplexNumber a, IComplexNumber b);
    IComplexNumber Divide(IComplexNumber a, IComplexNumber b);
    IComplexNumber Power(IComplexNumber a, IComplexNumber b);
}
</code>```

Body:
First of all, a simplification: all real numbers are a subset of complex numbers, so just do everything with complex numbers.

Secondly, why isn't Root supported by ComplexNumber?  If you're supporting complex numbers, then you can take the root of any number, including negative or complex ones.  It all just becomes vector multiplication.  So if it's all complex numbers, then you don't need to have ISupportedOperation, since every operation is supported (short of divide by zero, of course, but we usually handle that by throwing an exception).

Really, this should do:

interface ICalculator
{
    IComplexNumber Add(IComplexNumber a, IComplexNumber b);
    IComplexNumber Subtract(IComplexNumber a, IComplexNumber b);
    IComplexNumber Multiply(IComplexNumber a, IComplexNumber b);
    IComplexNumber Divide(IComplexNumber a, IComplexNumber b);
    IComplexNumber Root(IComplexNumber a, IComplexNumber b);
}

Remember, too, that a square root is just a^(1/2), so a more generic interface would be:

interface ICalculator
{
    IComplexNumber Add(IComplexNumber a, IComplexNumber b);
    IComplexNumber Subtract(IComplexNumber a, IComplexNumber b);
    IComplexNumber Multiply(IComplexNumber a, IComplexNumber b);
    IComplexNumber Divide(IComplexNumber a, IComplexNumber b);
    IComplexNumber Power(IComplexNumber a, IComplexNumber b);
}


问:
How does Twitter's "dogfooding" work? If they are using different URL's, how are they using their own API?
I heard that twitter practices "dogfooding," meaning that they use their own API for the website. However, I don't really understand how that's true. When I use Firebug, I see that all the AJAX calls are made to some URL like:

```<code>https://twitter.com/{username}/{whatever else}
</code>```

Rather than:

```<code>https://api.twitter.com/1.1/statuses/...
</code>```

If they are using different URL's, how are they using their own API? I think I have the wrong notion of what an API is... Also, how would it work with OAuth? Do they validate themselves?

答:
If they are using different URL's, how are they using their own API?

An API is software, while a URL points to a particular instance of said software.  It's perfectly sensible to have different installations of the same program for different audiences, exactly the same as Microsoft's internal git server being different than your own.

ContentLicense: CC BY-SA 3.0


问:
Administrator Rights for a set of code
I am developing a program for Windows 7 Enterprise Edition that will be used in a corporate environment. The application will automatically fix certain errors as soon as the user selects the application name, chooses the symptom or error message and clicking on the fix button.

The idea behind is to decrease the amount of calls we receive at the IT Service Desk (the company's personal Call Centre for IT Issues) and at the same time assist the end user by resolving the issue within a minute (versus waiting on the phone for up to 15 minutes or more).

I'm not yet allowed to upload an image of the application, but imagine a smallish Windows form with 2 columns, application name and symptom. The user will choose the application's name, click on the error message and click on the FIX button. This basically automates whatever we as IT Techs would do manually.

The problem I'm facing is that some of the code is supposed to be executed with administrator rights, e.g. Stop and Start a given service, adding registry entries for the local machine, etc.

Given the fact that none of the users will be allowed to have elevated rights and the fact that they need to use this application as a sort of "self-help" alternative without the need to call the IT Service Desk, is there a way to give a set of code "administrator permissions"? The application should NOT request the user to enter ANY passwords.

答:
As I understand it, the standard way of doing this is to create a service that runs with administrator rights and takes RPC calls from an unprivileged user application.  MSDN calls this the operating system service model. Another option is the elevated task model; again, see MSDN for more details.

As with any security-related software, don't trust the client.  (In this case, "the client" is the unprivileged user application.) If your administrator service or task takes commands like "execute support procedure A," then you're probably okay. If your administrator service takes commands like "start arbitrary service" or "write arbitrary registry key," then a malicious client could use it to effectively have full admin rights.

To elaborate: The client is under the control of the end user, which means that a malicious user can do anything they want to with it, including replacing it with a hacked or modified client that issues whatever commands they want.

If clicking "AppName" "ErrorMessage" "FIX" results in the client sending a "Fix AppName ErrorMessage" RPC call to the server, then you're fine. Even a malicious client can't do anything that a well-behaved client could.

Suppose, however, that the RPC interface is lower-level and the list of fixes is managed by the client.  Suppose that clicking "AppName" "ErrorMessage" "FIX" results in the client saying, "I know how to fix that. Service, write registry key AppName\A and restart service App Service B."  In that case, a mailcious client could say, "Service, write registry key CriticalWindowsSecurityKey\C and restart service Evil Hacker Service D." That would be bad.

Title: Administrator Rights for a set of code


答:
Put the "useful" stuff into a Windows Service and install that onto the user's machines.   Windows Services implicitly run "elevated".

Use your favourite cross-process communication method to send "requests" to the service from your user-visible utility program.  (I still favour using something based on TCP, if only because Windows Security hasn't poked its nose fully into those yet and you don't want the Security Contexts mixing here).  If you're really lucky, this might even work remotely, so your support staff have the option to run things on users' behalf, so long as the Service is running.  Why have two ways of doing the same thing?

The Service can only process requests that the user-visible, client application knows to ask about (there should not be a free-format "here's a DOS command; run it" option!) but the user never sees or interacts directly with the Service; just the visible, utility program.

When you need to add new functionality, deploy a new version of the Service executable - OK, fiddly, because you have to shut it down before you can update the physical file, but still perfectly possible - or deploy all the requestable "functions" as Dlls that the service loads at run-time (just remember to include a "request" to unload all of the "request" dlls!)

Title: Administrator Rights for a set of code

Body:
I am developing a program for Windows 7 Enterprise Edition that will be used in a corporate environment. The application will automatically fix certain errors as soon as the user selects the application name, chooses the symptom or error message and clicking on the fix button.

The idea behind is to decrease the amount of calls we receive at the IT Service Desk (the company's personal Call Centre for IT Issues) and at the same time assist the end user by resolving the issue within a minute (versus waiting on the phone for up to 15 minutes or more).

I'm not yet allowed to upload an image of the application, but imagine a smallish Windows form with 2 columns, application name and symptom. The user will choose the application's name, click on the error message and click on the FIX button. This basically automates whatever we as IT Techs would do manually.

The problem I'm facing is that some of the code is supposed to be executed with administrator rights, e.g. Stop and Start a given service, adding registry entries for the local machine, etc.

Given the fact that none of the users will be allowed to have elevated rights and the fact that they need to use this application as a sort of "self-help" alternative without the need to call the IT Service Desk, is there a way to give a set of code "administrator permissions"? The application should NOT request the user to enter ANY passwords.


问:
Organise C++ classes around SQL database
My question is about how best to organize C++ classes around a database
model, and I understand this may appear very elementary.

The software I propose to create will do the following. It is intended for
small FMCG manufacturers and will use Qt.

The software will record non-conformance's, product complaints,
corrective actions and serve as an electronic record keeping

There will be quite a bit of 'business logic', as the standout
feature is intended to be comprehensive reporting, searching and
analysis, as well as a flexible approach to entering data to smooth
workflows (ie, a break away from the "one screen per process stage"
paradigm)

The persistent store is an SQL database, with a table(s) for each
type of record (some records will be broken into separate tables for
investigations/solutions. This means that most work will be done on a
single row).

Each customer who uses this software will require amendments,
additional columns/fields or changes in column names and maybe
business logic. Each customer may require updates which change the
database structure. The idea is that anything that can be customized, any
client specific requirements will live within these classes.

There will be reporting, mainly involving pulling records matching
particular categories, word searches, etc.

I have the database schema done and laid out, and the logic of how tables
relate is clear.  I have used this very schema in another framework, but a web based app doesn't seem to offer the level of power to the user with regards to the GUI, which is essential to differentiate this product from the others.

My question is how to design classes around the database. It is important to
get this right, so that the architecture of the software doesn't have to be
redesigned later on. The classes will not be responsible for the persistent
store, only for acting as an intermediary between the layer responsible for
the persistent store and the controllers/views.

The most logical approach appears to be to have a class for non-conformances/complaints etc, which solely store the instance (ie, one object per non-conformance record), validate data and class specific business logic (ie, computations).  One class per table seems logical in this case.  What I'm struggling with, is whether it is standard practice to simply have data members for each column, define getters and setters, or whether I should create a class which isn't hard-coded to map to a table, but which populates a map based on the database schema or external file which defines the database and column properties. The former means that the coding for the class needs to be changed when columns are modified, the latter potentially not.  Keep in mind, for the majority of the time, each user will be working with one record at at time.

In short, I can see example of how to do SQL queries, but I've struggled to
find anything which shows me what the class should look like (or if this entire approach is wrong) and I'd like to compare what I'm doing, with what the industry would define as good practice (I'm not a programmer by trade).

Thank you,

答:
The first question is if you are okay with having to recompile the program every time the database schema changes. I'm not quite clear on your situation but for example:

You have a number of clients with slightly different needs (ie A needs to track Properties X, Y, Z, but B also needs to track Property W) but for a given client those needs are pretty constant. And you can work with and deploy a custom application to each client (aka you aren't selling this off the self). In that case, have a template that you can then inherit from and modify on a per client basis might be a pretty good business strategy, if the total number of clients is not high enough to make it worth creating a highly adaptable application right from the start. Having 5 different versions of the program is still maintainable, 100 is not.

On the other hand, if you have 100 clients you simply cannot be changing the code every time one of them wants to add a property (column) to something. Or even add a new type of object. So the program will need to be more dynamic, probably working off a relational map that is saved somewhere and that can be edited by the program as needed.

So lets assume what you have is more like the former. Having classes that represent the types of records you have is a good way to do it. Those classes can contain SQL queries directly. You should still however have things like table names as constants defined in a common .h file and then call them as constants in your actual code so any change needs to be made in only one place. Then if you need a slightly different object for a different client, you can inherit the classes you already have and make the necessary changes.

You could also put together an intermediary class that handles actual database interactions, so if you change the schema or even the type of database you are using, you just need to switch out or modify that class.


问:
Anybody use the Team Software Process (TSP) and/or Personal Software Process (PSP)?
More info on it here:
http://en.wikipedia.org/wiki/Team_Software_Process

What has your experience been?

答:
I took a class on PSP once, but never really used it. My short elevator ride description of PSP is that it's like SCRUM with more measurements. I worry, however, that some of the extra metrics can be used to inappropriately evaluate people - e.g. to reward or punish someone for their defect density.

I do like the discipline of estimation PSP pushes - I think estimation is a software development activity that has a lot of room for improvement, and I was able to measurably improve my estimation abilities throughout the course.

ContentLicense: CC BY-SA 2.5


问:
Is there a good reason to make pure functions non-public?
I had a little debate going on with a coworker. Simply put, is there a good reason to hide/encapsulate functions that are pure?

By "pure" I mean the wikipedia definition:

Always returns the same results from the same input. (For the sake of this discussion Foo Create(){ return new Foo(); } is considered impure if Foo does not have value semantics.)

Does not use mutable state (except local variables) or I/O.

Does not produce side effects.

答: A pure function could still be an implementation detail. Although the function may cause no harm (from the point of view of not breaking important invariants/contracts), by exposing it both the author and the users of that class/module/package lose. The author loses because now he can't remove it even if the implementation changes and the function is no longer useful to him. The users lose because they have to sift through and ignore extra functions that aren't relevant to using the API in order to understand it.</p>


答: I don't think the decision to hide/encapsulate a function should depend on its purity.  Just because a function is pure doesn't mean that externals need to know about it.  Interestingly enough though if the function is pure and meant to be public maybe it doesn't even need to be an instance member of the interface at all maybe it is better suited as a static.  But again all of this depends on the intent of the contract and in this case the logical grouping of functionality, not the purity of the function. </p>

Title: Is there a good reason to make pure functions non-public?

Body:
I had a little debate going on with a coworker. Simply put, is there a good reason to hide/encapsulate functions that are pure?

By "pure" I mean the wikipedia definition:

Always returns the same results from the same input. (For the sake of this discussion Foo Create(){ return new Foo(); } is considered impure if Foo does not have value semantics.)

Does not use mutable state (except local variables) or I/O.

Does not produce side effects.


答:
The question is backwards.

You don't seek for a reason to make a function non-public. It is an incorrect mindset to start with (in my opinion). The reasoning should go the other way.

In other words - don't ask "why would I make it private?". Ask: "why would I make it public?"

When in doubt, don't expose it. It's kind of like Ockham's razor - don't multiply entitites beyond necessity.

EDIT: Addressing counterarguments brought up by @Telastyn in comments (to avoid extended discussion there):

I've heard that over time, and even espoused it for quite some time,
  but in my experience, things tend to be too private.

Yes, it's a pain sometimes if a class is open for inheritance, but you can't override some private methods (whose behaviour you'd like to alter).

But protected would suffice - and it's still non-public.

It leads to a lot
  of code duplication and overhead to get at "things that shouldn't be
  public" yet are accessed indirectly anyways.

If it becomes problematic, then simply make it public! There's the necessity I was talking about :)

My point is that you shouldn't do it just in case (YAGNI and all).

Note that it's always easier to make a private function public than pulling it back to privacy. The latter is likely to break existing code.


答:
Classes should adhere to the Single Responsibility Principle. While a class may need to call on other functionality to achieve its goals, it should only expose functions that are part of its single responsibility.

Here is just one example of a case where visibility could cause a problem.

Consider a class that frobnicates widgets. Maybe as part of its frobnication code it needs some utility function that parses a string: perhaps it needs to transform the widget name in a way that standard string functions do not support.

Since this is a pure function (string comes in, transform it somehow, return a new string), it could be public or private without consequence. Or could it?

If you make it public, now your class has two responsibilities: frobnicating widgets, and transforming strings. This violates SRP, and can cause problems if other classes come to rely on the function. Since this is something you think is only used internal to the class, perhaps you change its interface or visibility. Now classes in other parts of the system are broken.

By keeping the function private, nobody ever has the opportunity to rely on code that is not part of the class's single responsibility.


问:
Concepts: API Level Testing
I'm college grad, soon to be graduating. SO i have started my job search. So my question is for New Grad who is interested in QA (API Level testing in particular). What is level of knowledge in JAVA required? I'm not that great in Java but can rate myself 5/10.

So do companies expect candidate to have extensive coding knowledge in java or just basic java

Again if its just basic java, what concepts should i focus more on ?

Thanks

答:
From your question, I assume that you're looking at a Java API testing gig (otherwise, java experience wouldn't make much of a difference).

Do you have experience in another language? As far as API testing goes, the basics of testing in one language apply to another.

What you want to be able to do is:

Look at the individual input values and identify potential problem values

Understand how input parameters can interact - or where they do not interact

Build a good oracle - i.e. know whether the API succeeded or not by knowing what behavior should happen beyond the return value

Keep usability in mind - since it's a public interface, can developers use the API to create a useful application?

Lot's more, but I'm slightly off topic on the answer. Again, the short answer is that if you are a 7-8+ on any language, I think you'll be fine as a java api tester.

Title: Concepts: API Level Testing


问:
In C#, can I do "this = ..." outside of a constructor?
Basically, can I do this, and what actually happens?

```<code>public class foo
{
    public int id;

    public void bar()
    {
        //do stuff

        this = null;    // ?
        //do stuff
        foo[] all = otherclass.FindAllFoos();
        foreach(foo f in all)
        {
            if(f.id == 42)
            {
                this = f;    // ?
                break;
            }
        }

        //do stuff
    }
};
</code>```

Some specific background that shouldn't matter:

The real project has a class that represents a USB device that I'm currently talking to, and just before this point in the program, I tell the device to reboot.  When the device comes back, it appears different enough to invalidate this instance, so I have to find it again among all the connected devices and continue talking to it.

答:
In C#, you cannot make an instance set itself to null.  this = null; will not work.  The functions and data that are defined inside of a class "live" in that classes instance.  If the instance is destroyed, everything associated with it is destroyed.

The bar() method should be moved into a different class, and manipulate foo classes.  For example:

```<code>public class FooManipulator
{
    private Foo _myFoo;

    public void bar()
    {
        var allTheFoos = otherClass.FindAllFoos();
        foreach(foo f in all)
        {
            if(f.id == 42)
            {
                this._myFoo = f;
                break;
            }
         }
    }
}
</code>```

Body:
In C#, you cannot make an instance set itself to null.  this = null; will not work.  The functions and data that are defined inside of a class "live" in that classes instance.  If the instance is destroyed, everything associated with it is destroyed.

The bar() method should be moved into a different class, and manipulate foo classes.  For example:

public class FooManipulator
{
    private Foo _myFoo;

    public void bar()
    {
        var allTheFoos = otherClass.FindAllFoos();
        foreach(foo f in all)
        {
            if(f.id == 42)
            {
                this._myFoo = f;
                break;
            }
         }
    }
}


答:
this=null

You cannot assign to this, it's read only for classes.

You can assign to this for a struct, but then a struct can't be null because its a value type.

Try putting it in an IDE?

Title: In C#, can I do "this = ..." outside of a constructor?

Body:
Basically, can I do this, and what actually happens?

```<code>public class foo
{
    public int id;

    public void bar()
    {
        //do stuff

        this = null;    // ?
        //do stuff
        foo[] all = otherclass.FindAllFoos();
        foreach(foo f in all)
        {
            if(f.id == 42)
            {
                this = f;    // ?
                break;
            }
        }

        //do stuff
    }
};
</code>```

Some specific background that shouldn't matter:

The real project has a class that represents a USB device that I'm currently talking to, and just before this point in the program, I tell the device to reboot.  When the device comes back, it appears different enough to invalidate this instance, so I have to find it again among all the connected devices and continue talking to it.


问:
Strategy vs Publiser-subscriber pattern
Let's say I have a channel endpoint where I receive messages. Because I want to process messages in a different way depending on its Header property, rather than create a massive   switch I create different strategies with the contract:

```<code>interface IMessageHandler
{
    String MessageHeader {get;}
    void Handle(Message msg);
}
</code>```

So then I can add new handlers for new messages without altering what is already there. But this leaves the door open to have multiple handlers that handle the same message kind. Or with a little change, make a handler able of handling several message kinds:

```<code>interface IMessageHandler
{
    Boolean CanHandle(Message msg);
    void Handle(Message msg);
}
</code>```

But... then it starts to look a lot to the pub/sub pattern, where the message Header property would be the topic to which handlers subscribe...

Where is the line that sepparate both patterns?

答:
A canonical Strategy implementation would have a single interface, IStrategy, with multiple implementations, AStrategy and BStrategy. Your application would then request an instance of IStrategy and receive an implementation dependent on the current state of the program. In this way, your IMessageHandler is an instance of the Strategy pattern (although you have encoded the decision of strategy within the interface itself which is where the similarity with Observer begins).

The Observer pattern is similar, but a key part is that you may have any number of observers. If you were to return a list of IMessageHandlers you would be a lot closer to the Observer pattern.

Ultimately the main difference is a semantic one. The Strategy pattern is used to determine how your function should execute; the Observer pattern is used to notify interested parties of an event or message.

Title: Strategy vs Publiser-subscriber pattern


问:
How can a new programmer impress the software engineer (boss)?
I'm working at my first programming job. My boss is a very smart software engineer, and I feel
like I have very little to offer compared to him. Problem is, he is always busy, and needs someone to help him out. I feel like I'm not good enough, but I still want to succeed. I want to be a great programmer.

What can I do to impress him?

Thank you.

答:
Having been a boss to programmers, I can tell you that nothing made me happier than when a programmer fixed a bug that I was to lazy to go fix!

So if you can, fix his bugs for him.


问:
When should you create/destroy underlying object in a class that wraps it
(note: I used Java to make it easer to explain my question, but the actual language is irrelevant for this dilemma)

TL; DR: I have a wrapper around some underlying class. At which point should I instantiate the underlying class (in the constructor, in a separate method, on first use) and why?

Lets say, for example, that I want to create a simple class to read from a file (it can actually be anything where the main functionality of a class depends on one or more underlying classes, but file reading seemed simplest to explain). This class will wrap around/simplify another class called File. In the past, I'd implement my file reader class this way:

```<code>class MyFileReader {
    private File file;

    public MyFileReader(String filename) {
        this.file = new File(filename);
    }

    public String read() {
        this.file.read(...);
    }
}
</code>```

Thus, the creation of my object immediately opens the file (if there's a possibility that the file doesn't exist, I'd throw an exception in the constructor).

Nowadays, I'd usually implement that class like this:

```<code>class MyFileReader {
    private File file;
    private boolean isOpen = false;

    public void open(String filename) {
        if (this.isOpen) close();
        this.file = new File(filename);
        this.isOpen = true;
    }

    public void close() {
        if (this.isOpen) {
            this.file.close();
            this.isOpen = false;
        }
    }

    public String read() {
        if (this.isOpen) {
            this.file.read(...);
        }
    }
}
</code>```

In other words, object creation is separate from actually opening the file (if there's a possibility that the file doesn't exist, I'd make the open method return a boolean indicating whether the class managed to open the file successfully) and it's possible for the object to exist without any file currently open.

Finally, another approach which I rarely used is to open the file "lazily", when it's first needed, like this:

```<code>class MyFileReader {
    private File file;
    private String filename;
    private boolean isOpen = false;

    public MyFileReader(String filename) {
        this.filename = filename;
    }

    public String read() {
        if (!this.isOpen) {
            this.file = new File(filename);
            this.isOpen = true;
        }

        this.file.read(...);
    }
}
</code>```

Now the question is - which one of these approaches is the best? And, since the answer is probably "it depends", what does it depend on and in which scenario(s) is each of these methods best applied?

答:
I think the real answer is a little bit subjective, but there are 3 scenarios coming to my mind(and there are more, for sure):

Decorator -> you pass the underlying object in the constructor

Proxy -> if the underlying object is expensive to create, delay its creation until you actually need it.

Singleton -> same as proxy, create the instance on demand if expensive


问:
Fork a subset of a repo - licensing and etiquette
I'm a contributor to a large open source project. I have made heavy changes to a submodule of that project to support more functionality, but at this point further improvements will be outside the scope of the original project. As such, I have pulled only the relevant files to the submodule into their own repo, and am proceeding with a major rewrite to allow for these new features. The file structure is such that this submodule can live on it's own, with the original as a dependency.

My question is, what are the licensing/etiquette issues I need to follow? At this point, the codebase only has traces of the original files left, but they did help get things started. With a BSD license on the original project, what do I need to do for my forked project to comply?

答:
With software licensed under BSD, you have freedom to add your own license, as long as you keep all the original copyright notices. This has been done extensively, both from BSD->GPL-family and from BSD->proprietary.

Etiquette is always fuzzy, but I'd say:

you make sure your repo contains a URL to what you forked from (i.e. more than just the legal minimum), and (if you've done branch filtering - please don't if you can avoid it) a script to create/update your repo from upstream (use exact hashes or tags instead of branch names, use GIT_AUTHOR_DATE, GIT_COMMITTER_DATE, etc for reproducible repos).

you make it very clear to upstream that you exist, and what your scope is

if you modify or create any purely utility functions, you keep them under a license that is useful to upstream.


问:
Why do most programming languages have special keyword or syntax for declaring functions?
Most programming languages (both dynamically and statically typed languages) have special keyword and/or syntax that looks much different than declaring variables for declaring functions. I see functions as just as declaring another named entity:

For example in Python:

```<code>x = 2
y = addOne(x)
def addOne(number):
  return number + 1
</code>```

Why not:

```<code>x = 2
y = addOne(x)
addOne = (number) =>
  return number + 1
</code>```

Similarly, in a language like Java:

```<code>int x = 2;
int y = addOne(x);

int addOne(int x) {
  return x + 1;
}
</code>```

Why not:

```<code>int x = 2;
int y = addOne(x);
(int => int) addOne = (x) => {
  return x + 1;
}
</code>```

This syntax seems more natural way of declaring something (be it a function or a variable) and one less keyword like def or function in some languages. And, IMO, it is more consistent (I look in the same place to understand the type of a variable or function) and probably makes the parser/grammar a little bit simpler to write.

I know very few languages uses this idea (CoffeeScript, Haskell) but most common languages have special syntax for functions (Java, C++, Python, JavaScript, C#, PHP, Ruby).

Even in Scala, which supports both ways (and has type inference), it more common to write:

```<code>def addOne(x: Int) = x + 1
</code>```

Rather than:

```<code>val addOne = (x: Int) => x + 1
</code>```

IMO, atleast in Scala, this is probably the most easily understandable version but this idiom is seldom followed:

```<code>val x: Int = 1
val y: Int = addOne(x)
val addOne: (Int => Int) = x => x + 1
</code>```

I am working on my own toy language and I am wondering if there are any pitfalls if I design my language in such a way and if there are any historical or technical reasons this pattern is not widely followed?

答:
It's because it's important for humans to recognize that functions are not just "another named entity". Sometimes it makes sense to manipulate them as such, but they are still able to be recognized at a glance.

It doesn't really matter what the computer thinks about the syntax, as an incomprehensible blob of characters is fine for a machine to interpret, but that would be nigh-impossible for humans to understand and maintain.

It really is the same reason as why we have while and for loops, switch and if else, etc, even though all of them ultimately boil down to a a compare and jump instruction. The reason is because it's there for the benefit of the humans maintaining and understanding the code.

Having your functions as "another named entity" the way you are proposing will make your code harder to see, and thus harder to understand.


答:
This might be useful on dynamic languages where the type is not that important, but it's not that readable in static typed languages where always you want to know the type of your variable. Also, in object-oriented languages it's pretty important to know the type of your variable, in order to know what operations it supports.

In your case, a function with 4 variables would be:

```<code>(int, long, double, String => int) addOne = (x, y, z, s) => {
  return x + 1;
}
</code>```

When I look at the function header and see (x, y, z, s) but I do not know the types of these variables. If I want to know the type of z which is the third parameter, I'll have to look at the beginning of the function and start counting 1, 2, 3 and then to see that the type is double. In the former way I look directly and see double z.

Title: Why do most programming languages have special keyword or syntax for declaring functions?

Body:
Most programming languages (both dynamically and statically typed languages) have special keyword and/or syntax that looks much different than declaring variables for declaring functions. I see functions as just as declaring another named entity:

For example in Python:

```<code>x = 2
y = addOne(x)
def addOne(number):
  return number + 1
</code>```

Why not:

```<code>x = 2
y = addOne(x)
addOne = (number) =>
  return number + 1
</code>```

Similarly, in a language like Java:

```<code>int x = 2;
int y = addOne(x);

int addOne(int x) {
  return x + 1;
}
</code>```

Why not:

```<code>int x = 2;
int y = addOne(x);
(int => int) addOne = (x) => {
  return x + 1;
}
</code>```

This syntax seems more natural way of declaring something (be it a function or a variable) and one less keyword like def or function in some languages. And, IMO, it is more consistent (I look in the same place to understand the type of a variable or function) and probably makes the parser/grammar a little bit simpler to write.

I know very few languages uses this idea (CoffeeScript, Haskell) but most common languages have special syntax for functions (Java, C++, Python, JavaScript, C#, PHP, Ruby).

Even in Scala, which supports both ways (and has type inference), it more common to write:

```<code>def addOne(x: Int) = x + 1
</code>```

Rather than:

```<code>val addOne = (x: Int) => x + 1
</code>```

IMO, atleast in Scala, this is probably the most easily understandable version but this idiom is seldom followed:

```<code>val x: Int = 1
val y: Int = addOne(x)
val addOne: (Int => Int) = x => x + 1
</code>```

I am working on my own toy language and I am wondering if there are any pitfalls if I design my language in such a way and if there are any historical or technical reasons this pattern is not widely followed?

Body:
This might be useful on dynamic languages where the type is not that important, but it's not that readable in static typed languages where always you want to know the type of your variable. Also, in object-oriented languages it's pretty important to know the type of your variable, in order to know what operations it supports.

In your case, a function with 4 variables would be:

(int, long, double, String => int) addOne = (x, y, z, s) => {
  return x + 1;
}

When I look at the function header and see (x, y, z, s) but I do not know the types of these variables. If I want to know the type of z which is the third parameter, I'll have to look at the beginning of the function and start counting 1, 2, 3 and then to see that the type is double. In the former way I look directly and see double z.


问:
What does 'upper bound' mean in context of BigO?
My computer science teacher says Big O has an upper bound but no lower bound. When I look at a graph of an algorithm mapped out using BigO though, there isn't an upper bound at all. The upper limit goes on forever. So what do it mean to say there is an upper bound in the context of BigO?</p>

答:
BigO is, simply put, a measure of algorithm complexity. In a best case scenario, even the worst algorithm may be finished in one operation/iteration. However, different operations have different average- and worst-case complexities. These worst-case complexities could be considered the upper bound.

So, how can we figure out the upper bound?

An algorithm will have different running durations based on the size of the data it is handling. As an example, let's consider a simple data structure, which could be implemented in a number of ways (let's use an array) and we decide that we want to search the structure for a piece of data. The number of operations you have to do will be based on the size of the collection of data. Let's assume there are n elements in the structure.

A typical array will, at worst case, iterate through the entire collection for this, meaning that you will perform up to n operations, resulting in O(n) complexity, so you have an upper-bound of n.

Let's assume that the data is sorted: you could now perform a binary search, resulting in log(n) operations, reducing the complexity with an upper bound of O(log(n)). It could still be completed in one operation, and if n approached an infinite number, the complexity would approach infinite execution time. This is probably what you were seeing in class. Different algorithm complexities approach this infinite execution level at different rates (n! > n^2 > n > log(n) > 1).

Edit: As per the comments, it should be noted that a change in the amount of data will also be reflected by a change in execution time based on the complexity. O(1) algorithms will not change, logarithmic ones will change in a logarithmic manner, linear algorithms linearly, etc. Essentially, doubling the amount of data may NOT double your execution time. You may quadruple it, or increase it by some smaller or larger factor.

For a more complex example, more work is required to figure out the complexity of course, but this is the general idea:

The Upper Bound of an algorithm's complexity describes how the algorithm's execution time changes with a change in the amount of data being processed in the operation, meaning that a more complex algorithm will often take an increasingly (often not linearly) long time to execute as the amount of data is increased.


答:
In my experience, as a general rule, you should instantiate the underlying object as soon as you have enough information to create it, and destroy it when the scope or object that owns it terminates. In other words, as soon as you know you don't need the information contained in it and can afford the runtime cost of destruction.

Considerations include:

Valid state of objects - does the wrapper object have any right to exist without the core? Objects should always exist in a valid state. If your wrapper needs the core object to make sense, you should instantiate the core as soon as you instantiate the wrapper.

Nullability - does it make sense for the wrapper to contain a null value? If so, it should contain a nullable reference. Does it make sense to swap out objects within the wrapper? If so, you should create the core objects when you know which object needs to be wrapped.

Ease of use - Does your interface make it easy for the client to use the functionality your object provides?

Ease of misuse - Does your interface make it easy to use your object wrong?

Ownership - who owns the underlying resource? They should decide when it gets destroyed.

If your file reader example, the second option make it easy to use the object wrong, because I can easily call read() before specifying which file to read.
I'd use either the first or last option, or maybe provide both by combining a variant of the last option with a factory function called get_open_file(filename).

Title: When should you create/destroy underlying object in a class that wraps it

Body:
(note: I used Java to make it easer to explain my question, but the actual language is irrelevant for this dilemma)

TL; DR: I have a wrapper around some underlying class. At which point should I instantiate the underlying class (in the constructor, in a separate method, on first use) and why?

Lets say, for example, that I want to create a simple class to read from a file (it can actually be anything where the main functionality of a class depends on one or more underlying classes, but file reading seemed simplest to explain). This class will wrap around/simplify another class called File. In the past, I'd implement my file reader class this way:

```<code>class MyFileReader {
    private File file;

    public MyFileReader(String filename) {
        this.file = new File(filename);
    }

    public String read() {
        this.file.read(...);
    }
}
</code>```

Thus, the creation of my object immediately opens the file (if there's a possibility that the file doesn't exist, I'd throw an exception in the constructor).

Nowadays, I'd usually implement that class like this:

```<code>class MyFileReader {
    private File file;
    private boolean isOpen = false;

    public void open(String filename) {
        if (this.isOpen) close();
        this.file = new File(filename);
        this.isOpen = true;
    }

    public void close() {
        if (this.isOpen) {
            this.file.close();
            this.isOpen = false;
        }
    }

    public String read() {
        if (this.isOpen) {
            this.file.read(...);
        }
    }
}
</code>```

In other words, object creation is separate from actually opening the file (if there's a possibility that the file doesn't exist, I'd make the open method return a boolean indicating whether the class managed to open the file successfully) and it's possible for the object to exist without any file currently open.

Finally, another approach which I rarely used is to open the file "lazily", when it's first needed, like this:

```<code>class MyFileReader {
    private File file;
    private String filename;
    private boolean isOpen = false;

    public MyFileReader(String filename) {
        this.filename = filename;
    }

    public String read() {
        if (!this.isOpen) {
            this.file = new File(filename);
            this.isOpen = true;
        }

        this.file.read(...);
    }
}
</code>```

Now the question is - which one of these approaches is the best? And, since the answer is probably "it depends", what does it depend on and in which scenario(s) is each of these methods best applied?


答:
The reasons that I can think of are:

It is easier for the compiler to know what we declaring.

It's important for us to know (in a trivial way) whether this is a function or a variable. Functions are usually black boxes and we don't care about their internal implementation. I dislike type inference on return types in Scala, because I believe that it's easier to use a function that has a return type: it is often the only documentation provided.

And the most important one is the following the crowd strategy that is used in designing programming languages. C++ was created to steal C programmers, and Java was designed in a way that doesn't scare C++ programmers, and C# to attract Java programmers. Even C#, which I think is a very modern language with an amazing team behind it, copied some mistakes from Java or even from C.


问:
Android: Is root absolutely required to re-link libs in Play Store APKs?
This question pertains to the re-link clause of the LGPL specifically on the Play Store.

There's lots of unclear information about this topic. Assuming there's an application on the Play Store that has a dynamically linked native library where the lib in question is a seperate *.so file in the APK, is it possible  to relink another version of that library you'd need to

Access and open the APK file somehow

Modify its contents

Run the modified APK

I know you can run unsigned APKs by modifying your device settings, but I don't believe you can access a Play Store APK without root access to your device.

Is root absolutely required to re-link libs in Play Store APKs? If it is, doesn't that imply that you cannot distribute an APK on the Play Store (or any store that protects user access to its APK files) that dynamically links to an LGPL library on a device that cannot be rooted?

Is this a valid concern (are there any devices that can't be rooted)?

Assume in this case that the distributors of the LGPL lib clearly require re-linking and don't provide any flexibility on that point.

edit:
It seems like there's a workaround that lets you download Google Play applications directly to your computer:
http://codekiem.com/2014/08/07/official-apk-downloader-v2-download-apk-files-from-google-play-store-to-pc/

I feel like this is a temporary fix though and might break at some point in the future. Still this seems to be a way to get an application without rooting your phone at all.

答:
IANAL. I only consider the LGPLv3 because there are huge wording differences.

Per section 4e, it is the responsibility of whoever "conveys" the "Combined Work" to also provide "Installation Information".

If you are the "conveyer", you can e.g. host the package on your own servers or whatever's convenient for you and use that in your "Installation Information".

If you are a user, nag/threaten the "conveyer" until they provide "Installation Information". I am fairly certain that, at some point, there have existed devices for which there is no known rooting mechanism, so I do not think "Installation Information" that requires rooting would be legit, unless they somehow restrict what models the package can be installed on.


答:
There is a very simple reason to have such a distinction in most languages: there is a need to distinguish evaluation and declaration. Your example is good: why not like variables? Well, variables expressions are immediately evaluated.

Haskell has a special model where there is no distinction between evaluation and declaration, which is why there is no need for a special keyword.


答:
I think the reason is that most popular languages either come from or were influenced by the C family of languages as opposed to functional languages and their root, the lambda calculus.

And in these languages, functions are not just another value:

In C++, C# and Java, you can overload functions: you can have two functions with the same name, but different signature.

In C, C++, C# and Java, you can have values that represent functions, but function pointers, functors, delegates and functional interfaces all are distinct from functions themselves. Part of the reason is that most of those are not actually just functions, they are a function together with some (mutable) state.

Variables are mutable by default (you have to use const, readonly or final to forbid mutation), but functions can't be reassigned.

From a more technical perspective, code (which is composed of functions) and data are separate. They typically occupy different parts of memory, and they are accessed differently: code is loaded once and then only executed (but not read or written), whereas data is often constantly allocated and deallocated and is being written and read, but never executed.

And since C was meant to be "close to the metal", it makes sense to mirror this distinction in the syntax of the language too.

The "function is just a value" approach that forms the basis of functional programming has gained traction in the common languages only relatively recently, as evidenced by the late introduction of lambdas in C++, C# and Java (2011, 2007, 2014).


答:
Personally, I see no fatal flaw in your idea; you may find that it's trickier than you expected to express certain things using your new syntax, and/or you may find that you need to revise it (adding various special cases and other features, etc), but I doubt you'll find yourself needing to abandon the idea entirely.

The syntax you've proposed looks more or less like a variant of some of the notation styles sometimes used to express functions or types of functions in mathematics. This means that, like all grammars, it will probably appeal more to some programmers than others. (As a mathematician, I happen to like it.)

However, you should note that in most languages, the def-style syntax (i.e. the traditional syntax) does behave differently from a standard variable assignment.

In the C and C++ family, functions aren't generally treated as "objects", i.e. chunks of typed data to be copied and put on the stack and whatnot. (Yes, you can have function pointers, but those still point at executable code, not at "data" in the typical sense.)

In most OO languages, there's special handling for methods (i.e. member functions); that is, they're not just functions declared inside the scope of a class definition. The most important difference is that the object on which the method is being called is typically passed as an implicit first parameter to the method. Python makes this explicit with self (which, by the way, is not actually a keyword; you could make any valid identifier the first argument of a method).

You need to consider whether your new syntax accurately (and hopefully intuitively) represents what the compiler or interpreter is actually doing. It may help to read up on, say, the difference between lambdas and methods in Ruby; this will give you an idea of how your functions-are-just-data paradigm differs from the typical OO/procedural paradigm.


答:
Turning the question around, if one isn't interested in trying to edit source code on a machine which is extremely RAM-constrained, or minimize the time to read it off a floppy disk, what's wrong with using keywords?

Certainly it's nicer to read x=y+z than store the value of y plus z into x, but that doesn't mean that punctuation characters are inherently "better" than keywords.  If variables i, j, and k are Integer, and x is Real, consider the following lines in Pascal:

```<code>k := i div j;
x := i/j;
</code>```

The first line will perform a truncating integer division, while the second will perform a real-number division.  The distinction can be made nicely because Pascal uses div as its truncating-integer-division operator, rather than trying to use a punctuation mark which already has another purpose (real-number division).

While there are a few contexts in which it can be helpful to make a function definition concise (e.g. a lambda which is used as part of another expression), functions are generally supposed to stand out and be easily visually recognizable as functions.  While it might be possible to make the distinction much more subtle and use nothing but punctuation characters, what would be the point?  Saying Function Foo(A,B: Integer; C: Real): String makes it clear what the function's name is, what parameters it expects, and what it returns.  Maybe one could shorten it by six or seven characters by replacing Function with some punctuation characters, but what would be gained?

Another thing to note is that there is an most frameworks a fundamental difference between a declaration which will always associate a name with either a particular method or a particular virtual binding, and one which creates a variable which initially identifies a particular method or binding, but could be changed at runtime to identify another.  Since these are very semantically very different concepts in most procedural frameworks, it makes sense that they should have different syntax.

Body:
Turning the question around, if one isn't interested in trying to edit source code on a machine which is extremely RAM-constrained, or minimize the time to read it off a floppy disk, what's wrong with using keywords?

Certainly it's nicer to read x=y+z than store the value of y plus z into x, but that doesn't mean that punctuation characters are inherently "better" than keywords.  If variables i, j, and k are Integer, and x is Real, consider the following lines in Pascal:

k := i div j;
x := i/j;

The first line will perform a truncating integer division, while the second will perform a real-number division.  The distinction can be made nicely because Pascal uses div as its truncating-integer-division operator, rather than trying to use a punctuation mark which already has another purpose (real-number division).

While there are a few contexts in which it can be helpful to make a function definition concise (e.g. a lambda which is used as part of another expression), functions are generally supposed to stand out and be easily visually recognizable as functions.  While it might be possible to make the distinction much more subtle and use nothing but punctuation characters, what would be the point?  Saying Function Foo(A,B: Integer; C: Real): String makes it clear what the function's name is, what parameters it expects, and what it returns.  Maybe one could shorten it by six or seven characters by replacing Function with some punctuation characters, but what would be gained?

Another thing to note is that there is an most frameworks a fundamental difference between a declaration which will always associate a name with either a particular method or a particular virtual binding, and one which creates a variable which initially identifies a particular method or binding, but could be changed at runtime to identify another.  Since these are very semantically very different concepts in most procedural frameworks, it makes sense that they should have different syntax.


问:
Are long compiles a thing of the past?
There are countless war stories about how long a compile can take.  Even xkcd made a mention of it.

Now, I haven't been programming for a long time and have mostly just been exposed to Java and Python (and Python is an interpreted language, not a compiled one). I realize it's possible that I just haven't come across projects that take very long to compile, but even for decent sized apps, it has either been instantaneous for me (usually handled in the background by an IDE) or taking no more than 30 seconds or so for an extremely large project. Even in a business environment (where the comic takes place), I've never had code take that long to compile.

Have I just not been exposed to projects with long compile times? Is this a relic of the past that is no longer something that happens in the modern day? Why would a compile take such a long time?

答:
A little of both. C++ (and C to a lesser extent) were notorious for their slow compilation times, especially on period hardware. Around the turn of the millennium, I worked on a project that took about 4 hours to build due to macro shenanigans.

These days things are better, but 30 seconds is fairly low in my experience - especially in formal builds where things need to be checked out from source control, unit tests run, installers built, and everything sent out to some SAN somewhere.

Title: Are long compiles a thing of the past?


答:
Compilation can take a while, especially for large projects written in languages like C, C++, or Scala. Compiling parts in the background can reduce the compilation time, but occasionally you have to do a fresh compile. Factors that can lead to long compilation times include:

Large code size, obviously. Large projects will have hundreds of thousands of lines of code.

C's #include preprocessor directive, which effectively causes the same code to be compiled hundreds of times. The macro system has similar issues, as it works on a text-level. The preprocessor really bloats up the code size that's actually passed to the compiler. Looking at a file after preprocessing (e.g. via gcc -E) should open your eyes.

C++'s templates are Turing complete, which means that in theory you can perform arbitrary computations at compile time. Nobody really wants to do that, but even lots of simple cases do add up to quite some time spent specializing the templates.

Scala is a fairly young language, and the compiler is horrendously under-optimized. Currently, the compiler uses a very large number of compilation passes (C is designed to require only two compilation passes). Typechecking is one of these passes, and can take some time due to the complicated type system featured by the language.

Compilation isn't the only thing that takes time. After the project has been compiled, a test suite should be run. The time spent on this can range from a few seconds to a couple of hours (if the tests are written badly).

Title: Are long compiles a thing of the past?

Body:
There are countless war stories about how long a compile can take.  Even xkcd made a mention of it.

Now, I haven't been programming for a long time and have mostly just been exposed to Java and Python (and Python is an interpreted language, not a compiled one). I realize it's possible that I just haven't come across projects that take very long to compile, but even for decent sized apps, it has either been instantaneous for me (usually handled in the background by an IDE) or taking no more than 30 seconds or so for an extremely large project. Even in a business environment (where the comic takes place), I've never had code take that long to compile.

Have I just not been exposed to projects with long compile times? Is this a relic of the past that is no longer something that happens in the modern day? Why would a compile take such a long time?


答:
It depends on the project and the environment in which it is compiled.  I've worked on C++ projects that took several minutes to compile (set up as multiple projects in MSVS), which is probably enough time for a swordfight.

If you work for a large company with a huge code and data base (Proctor and Gamble, Google, etc.) or for a small company or startup focused on one or two primary products which are very complex (e.g. scientific simulation and rendering), then waiting for a big project to compile is a realistic thing to expect even on powerful machines.  This can affect how you develop and debug code (as well as how often you choose to update and merge changes through versioning).

Title: Are long compiles a thing of the past?


答:
Functions are declared differently from literals, objects, etc. in most languages because they are used differently, debugged differently, and pose different potential sources of error.

If a dynamic object reference or a mutable object is passed to a function, the function can change the value of the object as it runs.  This kind of side effect can make it difficult to follow what a function will do if it is nested within a complex expression, and this is a common problem in languages like C++ and Java.

Consider debugging some sort of kernel module in Java, where every object has a toString() operation.  While it may be expected that the toString() method should restore the object, it may need to disassemble and reassemble the object in order to translate its value to a String object.  If you're trying to debug the methods that toString() will be calling (in a hook-and-template scenario) to do its work, and accidentally highlight the object in the variables window of most IDE's, it can crash the debugger.  This is because the IDE will try to toString() the object which calls the very code you're in the process of debugging.  No primitive value ever does crap like this because the semantic meaning of primitive values is defined by the language, not the programmer.


答:
You mentioned Java and Scala as examples. However, you overlooked an important fact: those aren't functions, those are methods. Methods and functions are fundamentally different. Functions are objects, methods belong to objects.

In Scala, which has both functions and methods, there are the following differences between methods and functions:

methods can be generic, functions can't

methods can have no, one or many parameter lists, functions always have exactly one parameter list

methods can have an implicit parameter list, functions can't

methods can have optional parameters with default arguments, functions can't

methods can have repeated parameters, functions can't

methods can have by-name parameters, functions can't

methods can be called with named arguments, functions can't

functions are objects, methods aren't

So, your proposed replacement simply doesn't work, at least for those cases.


答:
It's by no means a relic of the past. One of the projects I work on requires 45 minutes for a clean build from scratch. Aside from our own code we also have to pull and build the source from several large C and C++ libraries from external repositories. Compiling and linking C and C++ code is computationally expensive. As you point out, Python is typically implemented as an interpreted language, and Java usually uses a JIT (Just in Time) compiler, so your projects are skipping the upfront compilation and linking costs altogether. The price you pay is in longer start up times and (for Python at least) slower execution speed.

When build times get that long it becomes more important to take advantage of continuous integration systems like Jenkins or TeamCity. This allows individual developers to (mostly) avoid the pain of building from scratch, while still testing that changes aren't breaking the build.

Title: Are long compiles a thing of the past?


问:
Automating daily procedures
Is there a way to automate running VBA in Excel to clean up the file from inside an application?

Everyday my office has to confirm that 50 people have shown up for work on time. The scheduling software we use allows us to run a report and export in to 4 file types: HTML, RTF, CSV, and a text file. For what I am looking to do I have decided to use the Comma Separated Value export. I am able to import that CSV into Excel, clean it up, then import the results in MSSQL. What I am looking to do is run that section without any human interaction, other than specifying the file name of the CSV. My preferred language is C#, but I am flexible.

答:
You can use SQL Server to directly import CSV files without needing to go through Excel to perform "data clean up".

You have several methods to import data:

T-SQL's Bulk Insert command to load a CSV file. A good example is shown in Import CSV file into SQL Server on StackOverflow.

SQL Server Management Studio which can be automated using SSIS. Importing data using SQL Server Management Studio

bcp command line utility. It should be easy to export the CSV file to a single filename, which can then be scheduled to run automatically.

SQL Server Integration Services (SSIS) which was designed to load data from various sources. Different versions (i.e., 2005, 2008, 2008 R2, etc.) of SQL Server have different levels of capabilities. Please refer to the correct documentation for your version.

Lastly, roll your own:

In a VBA environment (like Excel) you will have to use Visual Basic for Applications as C# is not supported.

A standalone application can load the CSV, make a connection to the database, and perform INSERTs (if you are using SQL to get the data there). Optionally, you can use an Object Relational Mapping (nHibernate and Entity Framework are two very popular ORMs) to load your data.

Title: Automating daily procedures


问:
If your team does code review, to what extent do you verify that review fixes are carried out?
On my team, we carry out code reviews (without the use of external tools).  The reviewer produces a list of items which the developer should address or consider and then essentially leave them to it (after discussing with them the relevant points) without follow up on their subsequent changes.  Occasional spot checks suggest that for the most part all the comments are being addressed.

However, in a lot of literature on the subject of code-reviews there is a strong emphasis on verifying that the code review comments are addressed.  I'm wondering what people's thoughts are on this.  Does your team have (or had) issues with people not addressing comments?  Does your team behave like mine and not do the verification step?  If your team does do the verification step, how often is it just a rubber stamp exercise?

答:
My code reviewers come in different flavours but I mostly get rubber stamped. Certain code reviewers appear to want the process over as quickly as possibly, to the point where I've asked my team leader for one and his response was "yeah, that's fine; just put my name down", without actually looking at the code.

There's a contractor who can review my code (currently working on the same project), and will give occasional feedback but never produce comments. I get the impression that he's not overly concerned about the codebase as long as the result looks like it works. I've had to start flagging shortcuts that he's been taking, which isn't a situation I want to be in.

The two other team leaders are more thorough: they check every file, tell me to change things around, give advice and good feedback. Still no documentation is produced, aside from their names going against the commit.

The drawbacks of the decent reviewers are that the sessions last longer and I feel like my team leader could feel slighted if I stop asking him for reviews. I think our code reviews would be better without the reviewee present and done at the luxury of the reviewer.

Adrian's system sounds like a good one, but I doubt the management would go for it due to the extra time it would take.


问:
Why do some projects have getters and setters for public instance variables?
I was looking into an open-source game framework project written in Java. It has several classes that:

Have public instance variables.

Have getter/setters for such variables.

Generally, I write getters/setters when I want to encapsulate some behavior that occurs when a property is modified.

However, looking at the code, it literally goes something like this:

```<code>public class Test {
    public int value;
    public void setValue(x) {
        value = x;
    }
    public void getValue() {
        return value;
    }
}
</code>```

Then I thought about checking out the rest of the framework and see how do they modify such value, which may give me a hint on why did they do the above.

From what I've seen, they do it like this:

```<code>object.value = 100;
</code>```

Without using the getters/setters.

So now I'm not sure what was the point of creating getters/setters.

So, my question is, is there a reason I would want to create getters/setters for a public value, if such getters/setters don't even implement any kind of special behaviour?

答:
Not sure why you'd have a public member, unless it was static, const, readonly, etc.

I think public properties should always be preferred to public members; if you need to make changes to a public member, or whatever reason, it will mean any extant calls outside the class would need to be updated. Properties offer another layer to change things internally without (hopefully) having an impact outside of the class.

Supercat also makes an excellent point about interfaces.


答:
Other answers have already mentioned that yes, code on large projects, where large means 500k lines and up, can take significant times, especially when building from scratch.

The additional point is that some projects have to be built for multiple target environments. When the machines that host those environments are not available, the build must be done by cross-compilation, in serial on the machines that you do have. This can lead to significant build times. For one project I worked on, the nightly build would take 10 hours. Woe betide that you were the one who broke it!

I would add that you wouldn't get away with any such excuse for time wasting. A professional person should be planning their tasks so that they do have something useful to do in such periods.

Title: Are long compiles a thing of the past?


问:
Is this instance of mixing FP and OOP a good design?
I had a strange-feeling pattern come up in some code I was writing. In a project with user accounts, there was a lot of code that needed to do common things such as creating accounts, deleting them, logging them in and out, extending their logged-in session, etc. etc. etc. Now when I was first writing this, I just threw all those responsibilities into one class (which was horrible I know). When it was time to clean this up, I ended up going with an approach that felt right but also strange.

I set up an AccountAccessor class which held private functions for getting the data transfer objects associated with an account, then I made several "action" classes that each would do one thing with access to an account, letting me write:

```<code>new AccountPasswordSetter(new AccountAccessor(username)).SetPassword(password);
</code>```

This felt wrong, because

The action classes were very, very tightly coupled with the AccountAccessor class - there was no hope of testing them

The AccountAccessor class would have to expose it's data access functions for the action classes to use them.

I have to expose construction of the action classes to the client code. This felt problematic because really, there's no sensible reason anything outside the project needs to concern itself with their instantiation.

Each of the action classes only needed one of the data transfer objects the AccountAccessor provided - for example an action class responsible for logging the user out doesn't need access to the account's password.

Writing this feels very wordy and "inside out".

What I ended up doing instead was I made the action classes all able to be constructed only inside the project, and instead of needing an AccountAccessor I had them set up to simply accept a function that would take a connection to the database and return the one particular DTO they needed. Then, when the account accessor was constructed, would would create a whole slew of these action objects and pass each of them one of it's private methods for getting the DTO. Something like:

```<code>public class AccountAccessor {
    public AccountPasswordSetter PasswordSetter { get; private set; }
    public AccountSessionExtender SessionExtender { get; private set; }
    public string Username { get; private set; }

    public AccountAccessor(string username) {
        Username = username;
        PasswordSetter = new PasswordSetter(getPasswordEntity);
        SessionExtender = new SessionExtender(getSessionEntity);
    }

    private PasswordEntity getPasswordEntity(Connection databaseConnection) { ... }
    private SessionEntity getSessionEntity(Connection databaseConnection) { ... }
}
</code>```

Now, client code can simply call something like:

```<code>new AccountAccessor(username).PasswordSetter.Set(password)`
</code>```

The responsibilities are split up, and the action classes don't have to know or care about what an AccountAccessor is. The client code doesn't have to know or care about how the various objects that provide functionality are set up. The AccountAccessor only selectively exposes access to the database entities. This felt much, much better. What I liked most about this design was it solved a lot of the problems I was having without imposing any architectural headaches on the client code. If client code wants to log out an account and delete it, they just get an accessor then log it out and delete it – no need to work out how to properly pass objects around. The obvious approach for the client code just works.

But it still seems a little off – passing private methods as arguments to other objects comes across as fundamentally strange to me. I wanted to know more about what sort of problems this has, and what I should keep in mind when designing things fitting this sort of scenario in the future.

答:
I think your statements

```<code>new AccountPasswordSetter(new AccountAccessor(username)).SetPassword(password);
</code>```

and

```<code>new AccountAccessor(username).PasswordSetter.Set(password);
</code>```

cannot benefit from FP. It is good that you know Scheme, so I can use FP terminologies to explain: clearly the sole purpose of your above statements is to cause side effect.

The purpose of an expression is to compute a value, not to cause a side effect. The purpose of a statement is to cause a side effect.

The following statement should be clear enough:

```<code>user.Password = password;
</code>```

This is basic OOP, but inside the setter, you can use FP.

```<code>public string Password
{
    ...
    set { _password = Encrypt(value); }
}
</code>```

This time, Encrypt(value) is an expression, not a statement. The method can be tested independently if it is static. As long as the input is the same, the output is always the same, no matter there is a database or not. So you can break the complex operation to small and testable expressions.

Body:
I think your statements

new AccountPasswordSetter(new AccountAccessor(username)).SetPassword(password);

and

new AccountAccessor(username).PasswordSetter.Set(password);

cannot benefit from FP. It is good that you know Scheme, so I can use FP terminologies to explain: clearly the sole purpose of your above statements is to cause side effect.

The purpose of an expression is to compute a value, not to cause a side effect. The purpose of a statement is to cause a side effect.

The following statement should be clear enough:

user.Password = password;

This is basic OOP, but inside the setter, you can use FP.

public string Password
{
    ...
    set { _password = Encrypt(value); }
}

This time, Encrypt(value) is an expression, not a statement. The method can be tested independently if it is static. As long as the input is the same, the output is always the same, no matter there is a database or not. So you can break the complex operation to small and testable expressions.


答:
Large projects can take a long time.  It can be an hour or more for a big enough project.  There are a couple of libraries that I have to compile from source on my computer that take a very long time - e.g. opencascade.  The Linux kernel itself also takes quite a long time if you have to build it from scratch.  </p>

<p>However, there are other compilation-like processes that can take far longer.  Digital circuit design (either for ASICs or FPGAs) requires a place and route step.  The place and route step is where the placement of individual logic gates, flip-flops, registers, RAMs, and other components is determined along with the routing for the interconnect wiring.  The software uses timing models to determine the gate and routing delays for possible placements, compares these to the limits provide by the timing constraints, and then adjusts the placement locations and wire paths to try to get the timing requirements met.  Sometimes the software will even have to resize gates and add buffers in order to meet timing.  This step is extremely computationally intensive and can take many hours or even days to complete.  It also does not really parallelize very well.  There was an FPGA design that I was working on a year or so ago that consumed about half of a Virtex 6 HXT 565 FPGA (~300k out of 565k LUTs) and took about 7 hours to complete place and route.  I can't imagine how long it would take to run place and route on something like a Core i7 CPU design - probably at least several weeks.  </p>

Title: Are long compiles a thing of the past?

Body:
Large projects can take a long time.  It can be an hour or more for a big enough project.  There are a couple of libraries that I have to compile from source on my computer that take a very long time - e.g. opencascade.  The Linux kernel itself also takes quite a long time if you have to build it from scratch.

However, there are other compilation-like processes that can take far longer.  Digital circuit design (either for ASICs or FPGAs) requires a place and route step.  The place and route step is where the placement of individual logic gates, flip-flops, registers, RAMs, and other components is determined along with the routing for the interconnect wiring.  The software uses timing models to determine the gate and routing delays for possible placements, compares these to the limits provide by the timing constraints, and then adjusts the placement locations and wire paths to try to get the timing requirements met.  Sometimes the software will even have to resize gates and add buffers in order to meet timing.  This step is extremely computationally intensive and can take many hours or even days to complete.  It also does not really parallelize very well.  There was an FPGA design that I was working on a year or so ago that consumed about half of a Virtex 6 HXT 565 FPGA (~300k out of 565k LUTs) and took about 7 hours to complete place and route.  I can't imagine how long it would take to run place and route on something like a Core i7 CPU design - probably at least several weeks.


问:
Sequentially/parallel algorithm for extracting blob outer perimeter/contour length
I have labelled the connected components in a binary image and found their areas and bounding boxes. The components are not necessarily filled, and may contain holes. I wish to identify the component that resembles a pupil the most. For this, I would also like to extract (only) their outer perimeter lengths, for calculating circularity, since these are good features for pupil detection.

I plan to do this sequentially and then move the algorithm to CUDA afterwards, so the algorithm should be parallelisable to some extent. I should note that this work is for my thesis, and I am not asking you to solve anything for me, just provide some feedback on my research so far.

I investigated tons of articles for this problem, but it seems most of them are concerned with connected component labelling and not feature extraction. Alas, I found three candidates, and <s>two</s> one of my own design:

The Marching Squares algorithm. It sounds promising (also embarassingly parallel), but it appears to extract all perimeter lengths, including inner contours, without modification, which will likely overestimate perimeter lengths. However, since I am looking for the pupil, a homogenously colored area, it will likely not overestimate the pupil. The overestimation might also yield bad results for other irregularly shaped blobs, which should be fine if they are then not selected.

The Chain Code algorithm (used by OpenCV's findContours function): Seems pertty good as well, and parallel solutions do exist, but I worry it might fail if the stopping criterion is not good enough (see here, at the bottom near Jacob's stopping criterion). However, it should be able to extract only the outer contour and give good approximations.

The Convex Hull algorithms: While parallel solutions exist, I worry that it might make a blob more circular than it really is, if points are scattered in a way that favors this. Should give good results for the pupil blob though.

<s>Algorithm 1: You could launch some threads that trace from each side of the blob's bounding box towards the opposite side. When the threads "hit" a pixel with the blob's label, they mark it as visited and sum the hits. When another side is traced, visited pixel are ignored, hit pixels are summed again etc., and the total is returned.</s>

Algorithm 2: I also tried counting the number of pixels with a background pixel in their Moore neighborhood, but this overestimates the contour if enough holes are present.

I would appreciate some suggestions before I try to code everything since I am on a schedule. Again, I'm just asking for
advice, not solutions.

答:
I assume that you are not pursuing GPU computation just for the sake of it. In other words, you are willing to consider CPU or "traditional techniques", comparing multiple techniques, and finally choosing whatever gives the highest performance, instead of having to stick to using GPU in order to make a thesis.

I find that Chain Code (contour tracing) algorithm is sufficient for the task, if you smooth the contour coordinates afterwards.

In terms of concurrency and parallelism

If a collection of starting points for contour tracing is supplied, then contour tracing can be run independently by each agent working on one starting point. This is possible because contour tracing is non-destructive on the image or label matrix - it only reads neighbor values around the current position.

However, contour tracing is not data-parallel. In other words, it cannot be vectorized in a SIMD or SPMD machine.

Contours can have drastically different lengths. So, some agents will finish early, some will finish late. They will not have coherent flow-control patterns.

Also, the memory access patterns will be scattered all over the image. It will also be very wasteful on CPU caches - from each cache line, maybe only up to three pixel values will actually be meaningful for the contour tracing algorithm.

Is there a divide-and-conquer algorithm for contour tracing of a single blob?

I don't know. Please leave a comment if you find one, because I'd like to learn about that too. I haven't done a serious literature search so I may be ignorant. (Of course you should conceal it if it will form the backbone of your thesis.)

On the other hand, I have implemented a tile-based algorithm for connected-component labeling, based on labeling each tile independently and follow up with a "seam stitching" process, and finish off with a final label assignment. It is not data-parallel (not SIMD/SPMD) but it is highly parallelizable - the image can be divided into hundreds or thousands of tiles.

Regarding performance.

In a previous project where I used contour tracing, I was pleasantly surprised that contour tracing algorithms is in general much faster than the execution time for connected-component labeling algorithms, for the type of images I processed, because contour tracing does not perform as many memory operations as would be required by connected-component labeling.

Note that in general, contour-tracing and connected-component labeling aren't direct substitutes for each other - they give outputs in different representations, despite the outputs corresponding to the same blob. You may have to run both algorithms - label the whole image first, sample the "contour starting points", and trace out the contours of each.

Finding nested connected components.

There is an enhanced contour tracing algorithm which resolves nested connected component relationship.

Given the contour of the outer connected component,

Convert the chain code sequence into a sequence of markers.

There are two types of markers:

Marks the leftmost edge (begin X-position) of a horizontal run of pixels

Marks the rightmost edge (end X-position) of a horizontal run of pixels

Which marker is generated for the current chain code depends on the orientation of the current chain code.

Sort the marker sequence by vertical Y-position (major), and then by X-position (minor).

The sorted marker sequence then becomes a run-length raster descriptor of the blob surrounded by the contour.

Smoothing the contour coordinates into floating point.

The smoothing of contour coordinates will cause it to change from discrete (integers) to floating point. After that, you will find that the summation of the pairwise Euclidean distance is good enough for most purposes.

The exact detail of smoothing isn't important - for example, you can use Gaussian smoothing, applying it to the sequence of contour X and Y coordinates just like a 1D convolution. Keep in mind the circular (periodic / wraparound) nature of the sequence.

OwnerDisplayName: NordCoder


问:
Should fields still be private when you need to restructure the data?
I was taught that an object should know how to do everything with itself. So I've built an application trying to keep fields private and have a lot of methods like these:

DisplayGraphically()

DisplayAsText()

WriteToFile()

Apply()

Edit() (shows a dialog box to edit it)

ErrorCheck()

Now I want to save the data to another file format whose structure doesn't closely correspond to my object structure. It would feel easy if all the data was public. Then a single method could collect all the various bits of data from the objects and reorganize it to suit the file format. But this means exposing private fields (through getters). On the other hand, that's what an API would provide and surely doing this job through an API would be quite clean.

To sum up, which is better in what cases?

Fields are private. Objects have lots of methods to deal with many different uses.

Fields have public getters and setters which maintain correct internal state. New functionality that involves many objects can be encapsulated in its own class and doesn't require any modification of the existing code.

答:
You need to separate your data objects clearly from other application's classes, following the single responsibility principle. Most of the methods from your example should not belong to your data objects, they should belong to controller classes or other application classes, because the responsibility of your data objects should only be, well, to hold or manage their data, and not to interact with the file system or the user interface. If you start to restructure your application that way, your data objects (and only the data objects) will have most of their fields public accessible already.

For example, a method like DisplayAsText() which actually displays your object on screen does clearly not belong into any of your data objects. Instead, a method like ToString() could be part of your data objects, which is called from a method DisplayAsText() beeing part of a completely different class somewhere else in your application. A method like ErrorCheck could call a lot of small validation methods of your data objects telling if some state is right or wrong, and display the error, which means, the small validation methods should be part of your data objects, and ErrorCheck itself clearly not. And a method like Edit() will typically need complete read/write access to every data field of your data objects, so you should already have this available when starting to implement your SaveToNewFormat method.


问:
Questions about God's algorithm and Rubik's cube
I am creating Rubik's cube solver. It will be good if solver could solve cubes of any size and if it could generate short solutions.

I have found many various information about God's algorithm, which as I understand is able to solve various puzzles, not only Rubic's cube.

So I want to implement God's algorithm, but I cannot find any simple explanation of this algorithm.

In simple words, how does God's algorithm actually work?

答:
To get started with, God's Algorithm is not an algorithm. There is no particular way in which you can solve different permutations of cube with that algo.

What creators of god's algo did:

Partitioned the positions into 2,217,093,120 sets of 19,508,428,800 positions each.

Reduced the count of sets we needed to solve to 55,882,296 using symmetry and set covering.

And they wrote a program which used about 35 CPU years to find solutions to all of the positions in each of the 55,882,296 sets.

I hope this gives you a hint about how god's algo work.

What you can do -

Just store the 43,252,003,274,489,856,000 permutations of cube along with the solutions in a database and then everytime you get a scrambled cube, check in you database for that particular permutation of cube and then get solution. Easy. (Pun intended)

Anyways, here is a link that I found out which may help you - Coset solver source code


答:
You might be interested to learn that, way back in prehistoric times, a language called ALGOL 68 used a syntax close to what you propose.
Recognising that function identifiers are bound to values just like other identifiers are, you could in that language declare a function (constant) using the syntax

function-type name = (parameter-list) result-type : body ;

Concretely your example would read

```<code>PROC (INT)INT add one = (INT n) INT: n+1;
</code>```

Recognising the redundancy in that the initial type can be read off from the RHS of the declaration, and being a function type always starts with PROC, this could (and usually would) be contracted to

```<code>PROC add one = (INT n) INT: n+1;
</code>```

but note that the = still comes before the parameter list. Also note that if you wanted a function variable (to which another value of the same function type could later be assigned), the = should be replaced by :=, giving either one of

```<code>PROC (INT)INT func var := (INT n) INT: n+1;
PROC func var := (INT n) INT: n+1;
</code>```

However in this case both forms are in fact abbreviations; since the identifier func var designates a reference to a locally generated function, the fully expanded form would be

```<code>REF PROC (INT)INT func var = LOC PROC (INT)INT := (INT n) INT: n+1;
</code>```

This particular syntactic form is easy to get used to, but it clearly did not have a large following in other programming languages. Even functional programming languages like Haskell prefer the style f n = n+1 with = following the parameter list. I guess the reason is mainly psychological; after all even mathematicians don't often prefer, as I do, f = n ⟼ n + 1 over f(n) = n + 1.

By the way, the above discussion does highlight one important difference between variables and functions: function definitions usually bind a name to one specific function value, that cannot be later changed, whereas variable definitions usually introduce an identifier with an initial value, but one that can change later. (It is not an absolute rule; function variables and non-function constants do occur in most languages.) Moreover, in compiled languages the value bound in a function definition is usually a compile-time constant, so that calls to the function can be compiled using a fixed address in the code. In C/C++ this is even a requirement; the equivalent of the ALGOL 68

```<code>PROC (REAL) REAL f = IF mood=sunny THEN sin ELSE cos FI;
</code>```

cannot be written in C++ without introducing a function pointer. This kind of specific limitations justify using a different syntax for function definitions. But they depend on the language semantics, and the justification does not apply to all languages.

Body:
You might be interested to learn that, way back in prehistoric times, a language called ALGOL 68 used a syntax close to what you propose.
Recognising that function identifiers are bound to values just like other identifiers are, you could in that language declare a function (constant) using the syntax

function-type name = (parameter-list) result-type : body ;

Concretely your example would read

PROC (INT)INT add one = (INT n) INT: n+1;

Recognising the redundancy in that the initial type can be read off from the RHS of the declaration, and being a function type always starts with PROC, this could (and usually would) be contracted to

PROC add one = (INT n) INT: n+1;

but note that the = still comes before the parameter list. Also note that if you wanted a function variable (to which another value of the same function type could later be assigned), the = should be replaced by :=, giving either one of

PROC (INT)INT func var := (INT n) INT: n+1;
PROC func var := (INT n) INT: n+1;

However in this case both forms are in fact abbreviations; since the identifier func var designates a reference to a locally generated function, the fully expanded form would be

REF PROC (INT)INT func var = LOC PROC (INT)INT := (INT n) INT: n+1;

This particular syntactic form is easy to get used to, but it clearly did not have a large following in other programming languages. Even functional programming languages like Haskell prefer the style f n = n+1 with = following the parameter list. I guess the reason is mainly psychological; after all even mathematicians don't often prefer, as I do, f = n ⟼ n + 1 over f(n) = n + 1.

By the way, the above discussion does highlight one important difference between variables and functions: function definitions usually bind a name to one specific function value, that cannot be later changed, whereas variable definitions usually introduce an identifier with an initial value, but one that can change later. (It is not an absolute rule; function variables and non-function constants do occur in most languages.) Moreover, in compiled languages the value bound in a function definition is usually a compile-time constant, so that calls to the function can be compiled using a fixed address in the code. In C/C++ this is even a requirement; the equivalent of the ALGOL 68

PROC (REAL) REAL f = IF mood=sunny THEN sin ELSE cos FI;

cannot be written in C++ without introducing a function pointer. This kind of specific limitations justify using a different syntax for function definitions. But they depend on the language semantics, and the justification does not apply to all languages.


答:
We do code reviews for 100% of our code.

We use Fisheye which we've tied into our ticket tracking system, Jira

Reviewers are added to a ticket so that they can review the code.

They review and make comments in Fisheye

The developer manually makes changes as indicated, sometimes after discussion either online or in-person.

Additional 'rounds' of reviews may take place depending on the changes made after reviews.

Finally the review is closed.  There is NO specific 'step' to make sure changes have been applied.  Instead we rely on the fact that we are professionals, we are craftspeople, we care about our code.  I prefer this 'professional' approach to rigid procedural rules that people are afraid to break.  If a reviewer made a suggestion and we ignored it, it will usually surface soon in another context.

However this approach implies:

professionals that RESPECT each other

really good communication

agreement on standards

Really good communication actually includes a lot of factors such as:

physical layout.  members of the group not being in the main area is a frequent problem

scrum and scrum of scrums (to pass info with other teams)

retrospectives - to make sure the process works for everyone

Agreement on standards means:

either formal written or oral understanding of practices to use

systems that adapt to change

developers talking out differences and seeking agreement

retrospective on retrospectives - to look at our agile process itself.

Title: If your team does code review, to what extent do you verify that review fixes are carried out?

Body:
On my team, we carry out code reviews (without the use of external tools).  The reviewer produces a list of items which the developer should address or consider and then essentially leave them to it (after discussing with them the relevant points) without follow up on their subsequent changes.  Occasional spot checks suggest that for the most part all the comments are being addressed.

However, in a lot of literature on the subject of code-reviews there is a strong emphasis on verifying that the code review comments are addressed.  I'm wondering what people's thoughts are on this.  Does your team have (or had) issues with people not addressing comments?  Does your team behave like mine and not do the verification step?  If your team does do the verification step, how often is it just a rubber stamp exercise?