答:
If you need WS-* use WCF, you will not get it in Web API. This is mainly when you need interop with other systems using it otherwise I personally will avoid it like a plague.

ASP.NET Web API supports federated security via OAuth and OAuth 2.0 which is lighter and much simpler to understand, implement and support. There are other options such as Hawk, etc. But in any case, if I can choose, I will choose OAuth 2.0

Dominick Baier already has an implementation which I believe will become standard security. You can find it here http://thinktecture.github.io/

Title: Identity and Access Control in Web API vs WCF

Body:
Our team is looking to introduce Web API, MVC/ASP.NET implementation in our SOA. I am having a hard time trying to wrap my head around the identity and access control it has compared to WCF.

WCF has Windows, X.509, UserName, and WS-Trust (probably more, but this is what I am familiar with), MVC's Web API seems to only have web application based identity and access control built into it: Web Forms, Windows, and WS-Federation.

Has anyone made Web APIs using MVC that implements the protocols that WCF has?
Should this even be done / am I trying to use Web API in a way it shouldn't be?


问:
Understanding unit testing for dynamically changing condition
I was trying to understand how to write unit tests for a few days now. I'm confused with  following scenarios in the existing code.

In first function the max value changes depending on the object created at run time but in the second case it is a constant.

NOTE: The following functions are not related. These are two different scenarios.

SomeFunction1(arg1,....)
{
  if(arg1 > someObject.MaxAllowedValue)
  {
     throw exception;
  }
}
```

<pre class="lang-cs prettyprint-override"><code>SomeFunction2(arg1,....)
{
  if(arg1 > maxAllowedValue)
  {
     throw exception;
  }
}
</code>```

I am trying to test whether the function throws an exception when max value is exceeded.

Does the unit test remain the same in both the cases or is it different?

答:
TL;DR: 1) refactor your code 2) mock someObject

 Refactor your code

Congraz, you are just unit testing for a few days now and have learned one of the most important aspects of unit testing (especially when done early in the development process):

```<code>The act of writing a unit test is more an act of design
than of verification.
</code>```

(Uncle Bob, Agile Software Development, Principles, Patterns, and Practices)

So if SomeFunction1 and SomeFunction2 have closely related functionality and concerns, refactor them into one method. If not, you also need to write different unit tests for them since they cover different functionality/concerns.

 Mock

If your code still contains

```<code>if(arg1 > someObject.MaxAllowedValue)
</code>```

think about whether your current unit test should also test someObjects (probably not). If not, you should mock it, e.g. with EasyMock (this cheat sheet is helpful for both junit and EasyMock).

Update: Since you are testing another class, not that of someObject, it does not matter that someObject changes at runtime. All you have to do is cover all possible behaviors of your implementation under test with your tests, e.g.

arg1 == someObject.MaxAllowedValue

arg1 == someObject.MaxAllowedValue+1

ContentLicense: CC BY-SA 3.0

Body:
TL;DR: 1) refactor your code 2) mock someObject

 Refactor your code

Congraz, you are just unit testing for a few days now and have learned one of the most important aspects of unit testing (especially when done early in the development process):

The act of writing a unit test is more an act of design
than of verification.

(Uncle Bob, Agile Software Development, Principles, Patterns, and Practices)

So if SomeFunction1 and SomeFunction2 have closely related functionality and concerns, refactor them into one method. If not, you also need to write different unit tests for them since they cover different functionality/concerns.

 Mock

If your code still contains

if(arg1 > someObject.MaxAllowedValue)

think about whether your current unit test should also test someObjects (probably not). If not, you should mock it, e.g. with EasyMock (this cheat sheet is helpful for both junit and EasyMock).

Update: Since you are testing another class, not that of someObject, it does not matter that someObject changes at runtime. All you have to do is cover all possible behaviors of your implementation under test with your tests, e.g.

arg1 == someObject.MaxAllowedValue

arg1 == someObject.MaxAllowedValue+1


问:
How would I design an interface such that it's clear which properties may change their value, and which will remain constant?
I am having a design issue regarding .NET properties.

```<code>interface IX
{
    Guid Id { get; }
    bool IsInvalidated { get; }
    void Invalidate();
}
</code>```

Problem:

This interface has two read-only properties, Id and IsInvalidated. The fact that they are read-only, however, is by itself no guarantee that their values will remain constant.

Let's say that it were my intention to make it very clear that…

Id represents a constant value (which may therefore be safely cached), while

IsInvalidated might change its value during the lifetime of an IX object (and so shouldn't be cached).

How could I modify interface IX to make that contract sufficiently explicit?

My own three attempts at a solution:

The interface is already well-designed. The presence of a method called Invalidate() allows a programmer to infer that the value of the similarly-named property IsInvalidated might be affected by it.

This argument holds only in cases where the method and property are similarly named.

Augment this interface with an event IsInvalidatedChanged:

```<code>bool IsInvalidated { get; }
event EventHandler IsInvalidatedChanged;
</code>```

The presence of a …Changed event for IsInvalidated states that this property may change its value, and the absence of a similar event for Id is a promise that that property will not change its value.

I like this solution, but it's a lot of additional stuff that may not get used at all.

Replace the property IsInvalidated with a method IsInvalidated():

```<code>bool IsInvalidated();
</code>```

This might be too subtle a change. It's supposed to be a hint that a value is computed freshly each time — which wouldn't be necessary if it was a constant. The MSDN topic "Choosing Between Properties and Methods" has this to say about it:

Do use a method, rather than a property, in the following situations. […] The operation returns a different result each time it is called, even if the parameters do not change.

What kind of answers do I expect?

I am most interested in entirely different solutions to the problem, along with an explanation how they beat my above attempts.

If my attempts are logically flawed or have significant disadvantages not yet mentioned, such that only one solution (or none) remains, I would like to hear about where I went wrong.

If the flaws are minor, and more than one solution remains after taking it into consideration, please comment.

At the very least, I would like some feedback on which is your preferred solution, and for what reason(s).

答:
Another option would be to split the interface: assuming that after calling Invalidate() every invocation of IsInvalidated should return the same value true, there seems to be no reason to invoke IsInvalidated for the same part which invoked Invalidate().

So, I suggest, either you check for invalidation or you cause it, but it seems unreasonable to do both. Therefore it makes sense to offer one interface containing the Invalidate() operation to the first part and another interface for checking (IsInvalidated) to the other. Since it is pretty obvious from the signature of the first interface that it will cause the instance to become invalidated, the remaining question (for the second interface) is indeed quite general: how to specify whether the given type is immutable.

```<code>interface Invalidatable
{
    bool IsInvalidated { get; }
}
</code>```

I know, this does not answer the question directly, but at least it reduces it to the question of how to mark some type immutable, which is quiet a common and understood problem. For example, by assuming that all types are mutable unless defined otherwise, you can conclude that the second interface (IsInvalidated) is mutable and therefore can change the value of IsInvalidated from time to time. On the other hand, suppose the first interface looked like this (pseudo-syntax):

```<code>[Immutable]
interface IX
{
    Guid Id { get; }
    void Invalidate();
}
</code>```

Since it is marked immutable, you know that the Id will not change. Of course, calling invalidate will cause the state of the instance to change, but this change will not be observable through this interface.

Body:
Another option would be to split the interface: assuming that after calling Invalidate() every invocation of IsInvalidated should return the same value true, there seems to be no reason to invoke IsInvalidated for the same part which invoked Invalidate().

So, I suggest, either you check for invalidation or you cause it, but it seems unreasonable to do both. Therefore it makes sense to offer one interface containing the Invalidate() operation to the first part and another interface for checking (IsInvalidated) to the other. Since it is pretty obvious from the signature of the first interface that it will cause the instance to become invalidated, the remaining question (for the second interface) is indeed quite general: how to specify whether the given type is immutable.

interface Invalidatable
{
    bool IsInvalidated { get; }
}

I know, this does not answer the question directly, but at least it reduces it to the question of how to mark some type immutable, which is quiet a common and understood problem. For example, by assuming that all types are mutable unless defined otherwise, you can conclude that the second interface (IsInvalidated) is mutable and therefore can change the value of IsInvalidated from time to time. On the other hand, suppose the first interface looked like this (pseudo-syntax):

[Immutable]
interface IX
{
    Guid Id { get; }
    void Invalidate();
}

Since it is marked immutable, you know that the Id will not change. Of course, calling invalidate will cause the state of the instance to change, but this change will not be observable through this interface.


问:
Apache License 2.0 - Beginner
I'm building close-source application with some libraries that's using Apache License 2.0.

Number 4 point a) of the license stated that:

```<code>(a) You must give any other recipients of the Work or Derivative Works a copy of this License;
</code>```

Does this mean that my application is now under Apache License 2.0 because I included that license to my app?
Where should I include this license? In my source code or on the GUI?

Thanks.

答:
No, the Apache license isn't a "copyleft" license.  You must include the license in your stuff so that the end user knows that they are using something Apache licensed.  In your read me or wherever you plan on putting your license I would include a section that says uses Apache (whatever you are using here) Licensed under Apache 2.0 (license text here). If you have a click through agreement during the install then it is just another click through there. Basically put it as an addendum to wherever you were planning on putting your license.

The apache site has an FAQ about their license:

It requires you to:

include a copy of the license in any redistribution you may make that includes Apache software;

provide clear attribution to The Apache Software Foundation for any distributions that include Apache software.

Title: Apache License 2.0 - Beginner


问:
Is it considered Pythonic to have multiple classes defined in the same file?
In working with python for the first time, I've found that I end up writing multiple classes in the same file, which is opposed to other languages like Java, which uses one file per class.

Usually, these classes are made up of 1 abstract base class, with 1-2 concrete implementations who's use varies slightly. I've posted one such file below:

```<code>class Logger(object):

    def __init__(self, path, fileName):
        self.logFile = open(path + '/' + filename, 'w+')
        self.logFile.seek(0, 2)

    def log(self, stringtoLog):
        self.logFile.write(stringToLog)

    def __del__(self):
        self.logFile.close()

class TestLogger(Logger):

    def __init__(self, serialNumber):
        Logger.__init__('/tests/ModuleName', serialNumber):

    def readStatusLine(self):
        self.logFile.seek(0,0)
        statusLine = self.logFile.readLine()
        self.logFile.seek(0,2)
        return StatusLine

    def modifyStatusLine(self, newStatusLine):
        self.logFile.seek(0,0)
        self.logFile.write(newStatusLine)
        self.logFile.seek(0,2)

class GenericLogger(Logger):

    def __init__(self, fileName):
        Logger.__init__('/tests/GPIO', fileName):

    def logGPIOError(self, errorCode):
        self.logFile.write(str(errorCode))
</code>```

As seen above, I have a Logger base class, with a couple of implementation differences below that.

The Question:
Is this standard for python, or for any language? What problems could arise from using this implementation if any?

Please note: I'm not really looking for guidance on this specific file, but in a more general sense. What if the classes ended up being 3-5 moderately complex methods? Would it make sense to split them then? Where is the cutoff for saying you should split a file up?

答:
It's fine. It's fine in C++ as well, for reference.

Keeping tightly-coupled things together is sensible practice. Avoiding inappropriate coupling is also good practice. Striking the right balance isn't a matter of strict rules, but of, well, striking a balance between different concerns.

Some rules of thumb:

Size

Excessively large files can be ugly, but that's hardly the case here. Ugliness is probably a good enough reason to split a file, but developing that aesthetic sense is largely a matter of experience, so it doesn't help you figure out what to do a priori

Separation of Concerns

If your concrete implementations have very different internal concerns, your single file accumulates all those concerns. For example, implementations with non-overlapping dependencies make your single file depend on the union of all those dependencies.

So, it might sometimes be reasonable to consider the sub-classes' coupling to their dependencies outweighs their coupling to the interface  (or conversely, the concern of implementing an interface is weaker than the concerns internal to that implementation).

As a specific example, take a generic database interface. Concrete implementations using an in-memory DB, an SQL RDBMS and a web query respectively may have nothing in common apart from the interface, and forcing everyone who wants the lightweight in-memory version to also import an SQL library is nasty.

Encapsulation

Although you can write well-encapsulated classes in the same module, it could encourage unnecessary coupling just because you have access to implementation details that wouldn't otherwise be exported outside the module.

This is just poor style I think, but you could enforce better discipline by splitting the module if you really can't break the habit.

ContentLicense: CC BY-SA 4.0


问:
Best way to process a queue in C# (PDF treatment)
First of all let me expose what I would like to do : I already dispose of a long-time running webapp developed in ASP.NET (C#) 2.0. In this app, users can upload standard PDF files (text+pics). The app is running in production on a Windows Server 2003 and has a dedicated database server (SQL server 2008) also running Windows Server 2003. I myself am a quite experienced web developer, but never actually programmed anything non-web (or at least nothing serious).

I plan on adding a functionality to the webapp for which I would need a jpg snapshot of each page of the PDF. Creating these "thumbnails" isn't the big deal as such, I already do it inside my webapp using ghostscript. I've only done it on 1 page documents for now though, and the new functionality will need to process bigger documents.
In order for this process to be transparent aswell for the admins as the final users, I would like to implement some kind of queue to delay the processing of the thumbnails. There again, no problem to create the queue, it will consist of records in a table, with enough info to find the pdf document back.

Then I will need to process this queue, and that's were my interrogations start. Obviously the best solution to process it isn't an ASP script or so, so I will have to get out of my known environment. No problem, but I have no idea which direction to go. Therefore, a few questions :

What should I develop ? I presumably need something that is "standby" on the server, runs when needed, then returns to idle state until further notice.Should I be looking into Windows service ? Is there another more appropriate type of project ?

Depending on the first answer, what will be the approach ? Should I have somehow SQL server "tell" the program/service/... to process the queue, or should I have that program/service/... periodically check the state of the queue and treat new items. In both case, which functionality can I use ?

we're not talking about hundreds of PDF a day (max 50 maybe), I can totally afford to treat the queue 1 item at a time. Can you confirm I don't have to look much further on threads and so ? (I found a lot of answers talking about threads in queue treatment, but it looks quite overkill for my needs)

Maybe linked to the previous question : what about concurrent call to the program, whatever it is ? Let's suppose it is currently running, and a new record comes in the queue, what should be the behaviour ?

I don't need much detailed answers and would already be happy with answers like "You can do the processing with a service, and yes it's possible to have sqlserver on machine A trigger a service start on machine B" or "You have to develop xxx and then use the scheduler to run it every xxx minutes". I don't mind reading articles and so, but I can hardly afford to spend too much time learning stuff to finally realize I went the wrong way for this project, so basically I'm trying to narrow down the scope of matters I need to investigate.

Thanks for reading me, I hope I'll find some helping hands on here :-)

答:
Your requirements are pretty mild, so you can afford to write a very simple / easy to maintain solution.

In your case I'd probably write a console app & launch it via the task scheduler. The app would read the "queue", process any existing requests, then exit.  You could schedule it to run every 5 - 10 minutes or so.  Updating the code is easy - overwrite the file between scheduled runs.

You could also use a Windows Service (using TopShelf for example) - they're pretty easy to write, but then instead of exiting when finished you'd need to sleep.  Installing a new version gets to be a little bit more of a hassle than a console app, but not much.

If you start looking at higher volumes, you'd eventually want to eliminate the polling and probably move the queue out of the database & into something else (I have mixed feelings about MSMQ)


答:
My usual reference documents to know what is pythonic.

Simple is better than complex.

Flat is better than nested.

From The Zen Of Python

Almost without exception, class names use the CapWords convention.

Package and Module Names Modules should have short, all-lowercase
  names. [...] Module names are mapped to file names

From PEP 8

My interpretation is that it's fine as it would keep things simple and flat.
Also, because class names and file names have different cases, they are not supposed to be identical anyway so I wouldn't see any issue in packing multiple related classes in a file.

Title: Is it considered Pythonic to have multiple classes defined in the same file?

Body:
In working with python for the first time, I've found that I end up writing multiple classes in the same file, which is opposed to other languages like Java, which uses one file per class.

Usually, these classes are made up of 1 abstract base class, with 1-2 concrete implementations who's use varies slightly. I've posted one such file below:

```<code>class Logger(object):

    def __init__(self, path, fileName):
        self.logFile = open(path + '/' + filename, 'w+')
        self.logFile.seek(0, 2)

    def log(self, stringtoLog):
        self.logFile.write(stringToLog)

    def __del__(self):
        self.logFile.close()

class TestLogger(Logger):

    def __init__(self, serialNumber):
        Logger.__init__('/tests/ModuleName', serialNumber):

    def readStatusLine(self):
        self.logFile.seek(0,0)
        statusLine = self.logFile.readLine()
        self.logFile.seek(0,2)
        return StatusLine

    def modifyStatusLine(self, newStatusLine):
        self.logFile.seek(0,0)
        self.logFile.write(newStatusLine)
        self.logFile.seek(0,2)

class GenericLogger(Logger):

    def __init__(self, fileName):
        Logger.__init__('/tests/GPIO', fileName):

    def logGPIOError(self, errorCode):
        self.logFile.write(str(errorCode))
</code>```

As seen above, I have a Logger base class, with a couple of implementation differences below that.

The Question:
Is this standard for python, or for any language? What problems could arise from using this implementation if any?

Please note: I'm not really looking for guidance on this specific file, but in a more general sense. What if the classes ended up being 3-5 moderately complex methods? Would it make sense to split them then? Where is the cutoff for saying you should split a file up?


问:
Why was F# created?
For my current class, I have to pick and research a Programming Language (or popular scripting language) and answer quite a few questions about it, write a paper, and do some example programs displaying it's strengths and weaknesses compared to other languages.

I'm currently looking into F# as a possible candidate, my problem is I can't find any information stating (at least explicitly) why F# was created. I've found many strengths and a few weaknesses of F# but do these necessarily imply reasons as to why it was created?

Does anyone know any links or reads that would explicitly state why F# was created and/or the history of F# (particularly things like, what the creator was thinking, and stuff like that)?
And yes, I've been searching and will continue to, I just can only find implicit reasons, and I was hoping to find something stating explicitly reasons why F# was created.

答:
When .net originally came out it was supposed to be a platform that any language could run on top of, so there was a strong push by MS to port a large number of different types of languages to the .net platform.  You had microsoft contributing heavily if a project organically sprung up like ironpython, and if none did MS wrote it themselves. F# started as a port of OCaml to the .net framework to cover the strongly typed functional language spot that had no organic project.

Just in case the Don Syme link ever dies here is the main take away from it:

"The visional design of the .NET platform was very much expected to be a multilanguage platform from the start. Right back in 1998, just in fact as our research group in programming languages started at Microsoft and I joined the team and then other 10 of us joined the team, we were approached by a guy called James Plamondon, who started the project called Project 7, which was about getting 7 academic and 7 industrial programming languages on each side to target the .NET common language runtime and really check out if it was good enough, to see if design changes could be made early on in the design process of .NET to make sure it was good enough for a range of programming languages."

and a little further down

"I took what I learned from .NET Generics and saw that there was a chance to do a ML like language fitted very closely with .NET. During this time we had a go doing Haskell for .NET, we actually got a long way in doing that, but in the end there is quite a lot of dissonance between Haskell and .NET."

Title: Why was F# created?


问:
Why is Python written in C and not in C++?
In Python's tutorial one can read that Python's original implementation is in C;

On the other hand, the Python implementation, written in C, (...)

I'm very curious why was Python written in C and not C++?

I'd like to know the reasoning behind this decision and the answer should be supported by historical references (and not opinion based).

答:
A better question might be: "Why isn't Python written in Python?"

More to the point, once enough primitives for Python classes and objects are written in C, those can be used for writing the rest of the interpreter, so you wouldn't gain anything by using C++ instead.

ContentLicense: CC BY-SA 2.5


问:
Two components offering the same functionality, required by different dependencies
I'm building an application in PHP, using Zend Framework 1 and Doctrine2 as the ORM layer. All is going well. Now, I happened to notice that both ZF1 and Doctrine2 come with, and rely on, their own caching implementation. I've evaluated both, and while each has its own pro's and cons, neither of them stand out as superior to the other for my simple needs. Both libraries also seem to be written against their respective interfaces, not their implementations.

Reasons why I feel this is an issue is that during the bootstrapping of my application, I have to configure two caching drivers - each with its own syntax. A mismatch is easily created this way, and it feels inefficient to set up two connections to the caching backend because of this.

I'm trying to determine what the best way forward is, and would welcome any insights you may be able to offer.

What I've thought up so far are four options:

Do nothing, accept that two classes offering caching functionality are present.

Create a Facade class to stick Zend's interface onto Doctrine's caching implementation.

Option 2, the other way around - create a Facade to map Doctrine's interface on a Zend Framework backend.

Use multiple-interface-inheritance to create one interface to rule them all, and pray that there aren't any overlaps (ie: if both have a "save" method, they'll need to accept params in the same order due to PHP's lack of proper polymorphism).

What option is best, or is there a "None of the above" variant that I'm not aware of?

答:
Reasons why I feel this is an issue is that during the bootstrapping of my application, I have to configure two caching drivers - each with its own syntax. A mismatch is easily created this way, and it feels inefficient to set up two connections to the caching backend because of this.

Why not just tackle the issue from a "make configuration more convenient" standpoint?

In other words, write some new class that accepts your configuration data, and then applies it to both caching drivers. Sure, it isn't as flexible, but that also means less can go wrong.


问:
What arguments can I use to justify the use of either XML or JSON to store and transmit object data?
My project lead considers both of these approaches to be unnecessary overhead. I have been involved in and have witnessed a lot of talk around XML vs JSON, but this is the first time that I have heard an argument against BOTH.

We are using c# in .Net 4. We'll be storing data in a sql server database on the server and also on mobile devices. I've heard all the arguments between the two but now I need to understand the arguments for and against the use of any object notation to store data - my project lead prefers csv format.

答:
There are many libraries that will help you serializing and deserializing your data in XML or JSON. CSV is not so popular anymore, so you may need to do everything yourself. On top of that, both XML and JSON are probably easier to read for a human, which makes debugging easier and faster (i.e. cheaper).

CSV, on the other hand, has less characters for the same data so it takes less disk space and/or bandwidth.

Usually developer time (i.e. costs) is a much bigger constraint than disk space or bandwidth use, so most people will use XML or JSON. Using one or the other is a matter of which libraries you are most familiar with or even cultural reasons (Java and Scala people tend to use XML, Javascript people tend to use JSON). XML is more verbose (i.e. more disk, more bandwidth), but not to the point of being a problem in most modern projects.

If your boss is quite old, maybe he remembers the days when it made a difference to send data over the wire in a plain compact format (like CSV, or even an ad-hoc binary format) instead of XML, but that is very rarely an issue with modern computers and modern networks.


问:
As a software engineer, who should I be following on Twitter?
Who in the software engineering and software development fields uses Twitter to tweet about relevant happenings in the field?</p>

答:
These are all developers or people who post on technical topics, ordered by amount of interesting programmer-related content. The list is Mac-centric.

Matt Legend Gemmell

Wil Shipley

Jeff Atwood

John Gruber

John Siracusa


问:
When is a code considered tight and how does it increase efficiency of the code?
I have read many times that insertion sort has tight code and hence the hidden constant factor in its asymptotic complexity is smaller. I just read yesterday that quick sort has tight code just like insertion sort so it also has smaller hidden constant factor. It is one of the reasons it is considered best among the O(n lg n) sorting algorithms.

I don't understand what does it mean when someone says that this algorithm's code is tight. What does that mean exactly and how does it lead to improvement in the efficiency of the algorithm (the smaller hidden constant factor in asymptotic complexity)?

答:
When an algorithm is given a Big O designation such as O(n log n), it tells you how the algorithm will scale; that is, how well will it perform as you increase the size of n to a large number.

Let's say I have an algorithm that is O(n) over a data set.  That means that there's a loop in the code somewhere that executes n times, once for each element in the data set.  How long will it take to execute?  Assuming that each iteration of the loop takes about the same amount of time, it will take

m * n

Where m is the amount of time it takes to process one element of the data set.

It is clear that it will take longer to process the data set if m is higher.  Big O doesn't address that time at all; it only states that (in this case), the algorithm will scale linearly as a function of the data set size.

So a "tight loop" is simply one that has a smaller m.

This is the "hidden constant factor" that the book talks about.  Reducing m improves efficiency because any improvement in m will be multiplied over the whole data set.


问:
things to think of when moving into C-land
Hello

Over the years have I made a programming journey from C in 1990 to Pascal, C++ with I programmed commercially, java VHDL, C# and now I'm taking a look on F#.

In the spring I will go back to study embedded programming in C in a university course so before I do that I will refresh my knowledge in C.

I don't remember much of the C that I learnt and I think I am thankful for that for probably learned some bad habits back then.

I have some questions to get me on the way.

--edit--

To clarify: I am thankful for tips that have been given regarding embedded programming but now I am more interested in relearning C in general. Sorry if my question was unclear,

Compiler, Debugger, IDE? As a microslave I was thinking about 2010 C++ Express, any alternatives?

Where do you find good libraries with code for C. I'm thinking something similar to Boost, POCO in C++

Source for procedural programming patterns and best practices. Where can you find good code learn from?

Thanks in advance

Gorgen

答:
It depends on whether you will be working with 8/16 bit microcontrollers (without an OS) or 32-bit microprocessors using (for example) embedded Linux.  As others have mentioned, with the latter you will probably be using a gcc toolchain of some type.

However if you are going to be programming smaller devices, then the IDE and compilers are usually designed specifically for a family of MCUs.  Chip makers often sell (or give away) IDEs and compilers for their products (e.g. Microchip and Freescale).  (The free versions may be limited either by object size or optimization features).  There are some companies (like Keil and IAR) that make compilers for several different families.


答:
Tight code is source code that is very efficient in that it accomplishes a task with a minimum of resources and no superfluous code.

I want to display the sum of 1 and 3 in C#.  Program 1 accomplishes this task with tight code.  Program 2 does not.

Program 1:

```<code>class Program
{
    static void Main(string[] args)
    {
        Console.Write(4);
    }
}
</code>```

Program 2:

```<code>class Program
{
    static void Main(string[] args)
    {
        var myAdder = new Adder();
        Console.Write(myAdder.GetSum());
    }
}

class Adder
{
    public Adder()
    {
        this.FirstOperand = 1;
        this.SecondOperand = 3;
    }

    public int FirstOperand { get; set; }
    public int SecondOperand { get; set; }

    public int GetSum()
    {
        return this.FirstOperand + this.SecondOperand;
    }
}
</code>```

Title: When is a code considered tight and how does it increase efficiency of the code?

Body:
I have read many times that insertion sort has tight code and hence the hidden constant factor in its asymptotic complexity is smaller. I just read yesterday that quick sort has tight code just like insertion sort so it also has smaller hidden constant factor. It is one of the reasons it is considered best among the O(n lg n) sorting algorithms.

I don't understand what does it mean when someone says that this algorithm's code is tight. What does that mean exactly and how does it lead to improvement in the efficiency of the algorithm (the smaller hidden constant factor in asymptotic complexity)?

Body:
Tight code is source code that is very efficient in that it accomplishes a task with a minimum of resources and no superfluous code.

I want to display the sum of 1 and 3 in C#.  Program 1 accomplishes this task with tight code.  Program 2 does not.

Program 1:

class Program
{
    static void Main(string[] args)
    {
        Console.Write(4);
    }
}

Program 2:

class Program
{
    static void Main(string[] args)
    {
        var myAdder = new Adder();
        Console.Write(myAdder.GetSum());
    }
}

class Adder
{
    public Adder()
    {
        this.FirstOperand = 1;
        this.SecondOperand = 3;
    }

    public int FirstOperand { get; set; }
    public int SecondOperand { get; set; }

    public int GetSum()
    {
        return this.FirstOperand + this.SecondOperand;
    }
}


问:
LIcense Issues Of Publishing A WordPress Theme, Built With Roots Theme, At Themeforest
I want to develop a WordPress theme using Roots theme framework and then sell it on themeforest.net.

Roots theme license allows me to sell the theme as per its founder's discussion with some guy on this google group post.

It says that the product should have an MIT compatible license. The question is:-

If I sell it on themeforest then will it be under compliance with the MIT license? I believe that themeforest has its own 'regular license'.

Will the purchaser of the theme have the right to modify my theme's source code and sell it again on themeforest?

Note: I don't have much knowledge of the licenses, that's why I'm here. Please don't ask me to read the license because I'm unable to understand their complex English. "INCLUDING BUT NOT LIMITED", "AS IS", "TORT OR OTHERWISE" etc. Can't understand it clearly.

答:
Given the completely different nature and scope of the themeforest.net licenses and the MIT license, it is very hard for a non-lawyer to determine if they are compatible. The only way to get any level of confidence is to ask a lawyer or the author of the Roots framework.

The themeforest.net licenses are quite restrictive licenses for using a software product.

The MIT license is a very permissive license centering around modification of source files.

How the usage restrictions from the themeforest.net license interact with the freedoms from the MIT license is hard to predict. In my, non-expert, opinion, it can go any way.

There is a case to make that for a buyer only the themeforest.net license is relevant,

There is a case to make that both licenses apply and that the themeforest.net restrictions are effectively cancelled, and

There is even a case to make that both licenses apply and are incompatible (resulting in a product that you can't sell).

The only way to know for sure which it will be is to go to court. A second best option is to ask a lawyer who specialises in this kind of stuff.


答: What you have now is fine.  Go and browse the standard library - there's plenty of modules with multiple related classes in a single file.   At some point, things get bigger and you eventually will want to start using modules with multiple files but there's no real rules as to when.   Things just get split when one file starts feeling 'too big'.</p>


问:
Multiple Dispatch and CLOS
I have never written software in Common Lisp, but in Scheme and Clojure as well as C++ and Python. Yet I have had a look at the Common Lisp Object System (CLOS) in Common Lisp and Dylan. Now when comparing it to OOP in the Simula tradition, CLOS and lets say C++ and Python class system have polymorphism as a common trait.

They seem to differ in the way how data and methods are organized, in the Simula family, methods are an integral part of classes, sub-items if you will while with CLOS they are defined outside of classes and are rather generalized procedures.

Common Lisp proponents typically argue that virtual methods in Simula-family programming languages are quite limited since they are invoked only according to the first-argument object (this or self). CLOS generic functions are selected for several arguments, thus something like (pseudo code)

```<code>method draw(c : Device, d : Drawable) ...
</code>```

can be implemented for arbitrary Canvas and Drawable combinations.

```<code>method draw(c : Printer, t : Triangle)....
method draw(c : Printer, t : Image)....
method draw(c : Screen, t : Image) ....
</code>```

In Simula-family languages, this would be more difficult, since draw would have to be associated with either the Device or the Drawable family of objects. The canonical solution seems to be the Visitor Pattern http://en.wikipedia.org/wiki/Visitor_Pattern .

Upon learning CLOS, I was quite amazed that most OO programming languages do not offer multiple dispatch - and - wondered if there are specific reasons, why one might associate methods so closely with one specific class. Are there specific advantages for single dispatch?

ambiguity of multiple dispatch: i.e. lets say I have a subclassing A and b subclassing B. The method foo(A,B) implemented as foo(a,B) and foo(A,b), which implementation would a call of  foo(a,b) invoke? Is this the only reason?

"Modularizing", methods in the class are near.

Is there more to it? Have language designers and creators taken a stance on this matter?

答:
There are now several languages which support multiple dispatch. There are extensions for some. Perl/Moose, Dylan, Julia, ...

Single dispatch object-oriented language have some things which can be seen as an advantage:

a class can be a namespace. In CLOS classes are not namespaces.

methods can be in a class namespace. In CLOS methods are not in a class namespace. Thus to have shorter access to variables and accessors, CLOS uses macros WITH-SLOTS and WITH-ACCESSORS.

in a class/message-passing system, all messages can be forwarded to another object with a single action.

a class could have a handler for all messages it does not understand. In CLOS this would look a bit more difficult.

performance may be a problem in a CLOS-like system due to the mix of multi-methods and multiple-inheritance.

source code organization and finding methods could be more difficult or at least be different in a CLOS like system.

Title: Multiple Dispatch and CLOS


问:
Best practices for rotating large datasets?
[edit]Turns out there's 1.5 million records... The SQL database is taking about 17-20 seconds to run the query. Would it be best to have Java handle the joins and rearranging in that case? Since this is a web app, if multiple users are getting Excel exports, would the long queries reduce the overall performance of the site?[/edit]

I have a dataset that contains roughly 70,000 records. For simplicity's sake, let's say the data currently looks like this:

User ID | Question | Answer

In our web application, the data needs to be rotated 90 degrees and exported into Excel, such that we have the following:

User ID | Question 1 | Question 2 | Question 3 ....

I think we end up with around 50 or so columns.

Should the data be rearranged on the database side using pivot tables or should it be rearranged on the application side?
Which solution would be the easiest to maintain?
Which solution would have the greatest performance?

答: Since you are exporting data, in this situation I'd typically build the export file manually in code.  Pull back the rows sorted by user id, and loop through them.  While the dataset would be large, the query itself would be very simple and shouldnt stress the database much.  No need to otherwise burden the sql server with keeping the 'compiled' data set maintained when its not needed.</p>


答:
It depends.

Usually app tiers are easier to scale horizontally than databases. So when possible, doing more on the app tier (or client), and less on the DB allows you to throw hardware at the problem if 100 users decide to run their 20 second query at once.

If you don't care about scalability, then I'd look at the explain plan for the query first, and what causes it to be slow. It might be possible to make it faster server side.

Title: Best practices for rotating large datasets?

Body:
[edit]Turns out there's 1.5 million records... The SQL database is taking about 17-20 seconds to run the query. Would it be best to have Java handle the joins and rearranging in that case? Since this is a web app, if multiple users are getting Excel exports, would the long queries reduce the overall performance of the site?[/edit]

I have a dataset that contains roughly 70,000 records. For simplicity's sake, let's say the data currently looks like this:

User ID | Question | Answer

In our web application, the data needs to be rotated 90 degrees and exported into Excel, such that we have the following:

User ID | Question 1 | Question 2 | Question 3 ....

I think we end up with around 50 or so columns.

Should the data be rearranged on the database side using pivot tables or should it be rearranged on the application side?
Which solution would be the easiest to maintain?
Which solution would have the greatest performance?


问:
Is there any way to get faster at solving bugs? I've just had a warning from my boss
I've just been told by my boss that I will receive a negative performance review on Monday. He wants to talk to me about why I am so slow and why my bug fix rate is so low.

I love programming and solving problems but I actually do find my job really really hard.

I've actually been a programmer for about 10 years. But this is my first multithreading embedded linux job - I've been here 2 years and it's obvious to everyone that I'm still struggling. And I think I've become so demoralised and feel so marginalised that I've lost a lot of the fire that I had at the start of the job.

Has anyone ever been in a similar situation and how do you go about increasing your bug fix rate?

Update:
I had the review. I have been put on a 3 month 'employee development program' (of the type mentioned by Dunk ). Not sure whether I can turn this around. But even if I do have to move on, I've learned a lot from this experience.

Another Update

It's now about 6 weeks since the first review.
My advice to anyone facing the same situation is to be humble enough to take criticism and learn from your mistakes. And to not be afraid to look dumb. Ask loads and loads of questions. Let people know you're trying to learn and keep asking until you understand.
But be prepared for it not to work out. I'm constructing a portfolio of code ... as well as giving it my best shot.

Yet another update

I am hesitant to put this on here, since I'm concerned that I will not be able to refer future employers to my stackoverflow profile... But anyway, it might be of interest for someone reading this question, but I actually lost my job a few weeks ago. I'm in the midst of brushing up on all the skills I need to - I've taken a lot from the advice given here.

答:
I've been in similar situations because I was afraid of asking for help. Judging by what you said in this comment...

"But what's frustrating is that there are certain tools/tips/tricks I
  only found out after being there a year and a half. I've been shifted
  round from team to team ( I guess cos I was underperforming ) and I'm
  discovering these 'hidden' tools every so often."

...you may have had the same problem I did. Debugging is as much a craft as writing code that doesn't require as much debug in the first place. Watching other devs work through a debug problem can be highly educational. Ask them for help when you're having trouble sorting something out. Especially if you're covering ground that you haven't before. And do so ideally before it's time to panic because you're not getting anything done.

That said, I do agree with the comments that management was doing something wrong. If somebody is struggling with something, they should be getting help with that before the negative review fun begins. Hell, if anybody on a team is struggling and never gets help I'd say every member of that team is doing something wrong (although that could be a direct result of people watching their bug fix rates overly closely).


答:
What's missing from the OP is any mention of a repeatable process or method that's being followed to resolve bugs.

So, first, document the process that you follow. Be sure to document what each step in the process is meant to achieve.

You can outline the process as having tasks like this:

Be sure you understand exactly what the issue is that is being reported.

Try to reproduce the issue.

Start breaking down the problem into smaller pieces

Think of possible causes of the problem.

Test those hypotheses

It would be helpful to know if the bugs have existed for a long time, or are being introduced with recent changes. If the bugs have been introduced with recent changes doing code reviews and/or just reading the code that people are creating can help.

I think that if you can clearly define the problem, for example, "I have trouble thinking of hypotheses to test when trying to resolve bugs" then you can get more focused advice.

Title: Is there any way to get faster at solving bugs? I've just had a warning from my boss

Body:
I've just been told by my boss that I will receive a negative performance review on Monday. He wants to talk to me about why I am so slow and why my bug fix rate is so low.

I love programming and solving problems but I actually do find my job really really hard.

I've actually been a programmer for about 10 years. But this is my first multithreading embedded linux job - I've been here 2 years and it's obvious to everyone that I'm still struggling. And I think I've become so demoralised and feel so marginalised that I've lost a lot of the fire that I had at the start of the job.

Has anyone ever been in a similar situation and how do you go about increasing your bug fix rate?

Update:
I had the review. I have been put on a 3 month 'employee development program' (of the type mentioned by Dunk ). Not sure whether I can turn this around. But even if I do have to move on, I've learned a lot from this experience.

Another Update

It's now about 6 weeks since the first review.
My advice to anyone facing the same situation is to be humble enough to take criticism and learn from your mistakes. And to not be afraid to look dumb. Ask loads and loads of questions. Let people know you're trying to learn and keep asking until you understand.
But be prepared for it not to work out. I'm constructing a portfolio of code ... as well as giving it my best shot.

Yet another update

I am hesitant to put this on here, since I'm concerned that I will not be able to refer future employers to my stackoverflow profile... But anyway, it might be of interest for someone reading this question, but I actually lost my job a few weeks ago. I'm in the midst of brushing up on all the skills I need to - I've taken a lot from the advice given here.


问:
Is it possible to write an operating system in C?
A while back I saw a comment on a Stack Overflow question that surprised me:

No one can write an operating system in C. It is not possible. What
  one can do is write an operating system in a C-based/C-like language
  that adds/defines a considerable amount of non-standard capabilities
  on top of C core.

Is it useful to define C so narrowly? People say Linux, or a GPU driver, or an embedded system was "written in C", not "written in C-with-some-extensions-to-accommodate-the-hardware."

Is it incorrect to do so?

答: I think that whoever wrote that comment doesn't know what he's talking about because the reason behind C's creation was to write Unix (one of the best operating systems of all time) I'm not saying it's the best language to write an operating system with because many things have changed since the creation of Unix, and now there are many languages that are better than C when it comes to writing an operating system , but it's far from impossible to write an OS with C.


问:
Is it bad to place "include directive" within main function?
It is always said that the include directives should be placed at the beginning of a script. The main reason is to make the functions available throughout the script. Regardless of this fact, is it bad to place an include directive within the main function where it is needed?

For example,

```<code>#include <stdio.h>
int main() {
#include <mysql.h>
}
</code>```

Instead of

```<code>#include <mysql.h>
#include <stdio.h>
int main() {
}
</code>```

I was unable to find any different in performance or compiled file size, but it is difficult to judge about this fact based on simple scripts. I wonder if it has any effect or drawback, or any reason to avoid this non-standard approach.

答: long things short ... just avoid it as much as you can , do it only when it's Absolutely necessary (I can't think of a case where it is but who knows), in order to have a clean maintainable code.


答:
The question is quite broad and as it stands the answer is yes. In fact, the answer is yes for most programming languages but there is a catch.

You need to translate your OS code into something that the machine understands. And it is the machine and its native language and your capability to translate from "your" language to the "native" language that would determine if you can write an operating system in your language or not.

General Theory

Let's say a machine has a lever. And only two things are possible -when the lever is pushed down the machine shall pour coffee and when pulled up the machine shall stop pouring coffee. Now imagine my native language translator is a human who can read C code printed on a paper and decide whether to push the lever up or down. So, for example upon reading the following line our human "compiler-linker" will push the lever down.

```<code>printf("pour coffee"); //Support more similar syntax in later versions!
</code>```

And on reading the following line our human "compiler-linker" will pull the lever up.

```<code>printf("stop pouring coffee"); //Support more similar syntax in later versions!
</code>```

We have successfully written an operating system for this coffee machine entirely in C. For that matter, we can train our compiler to translate Java, C#, KSH, Perl, English, Slavik, Sanskrit etc… and "operate" the machine. Hence the term, Operating System.

Of course most modern computers are capable of doing something more complex than this. And hence the complexity of their instruction set goes beyond just a simple lever state. These instruction sets will ultimately just put some transistors/magnets/LEDs etc. in some state and we humans will interpret that as a result.

The problem hence becomes one of manipulating this machine to achieve the states we want. And if your language (e.g., C) can be translated into that native instruction set and if you can use this bridge to make the machine do what you want then you shall have a successful operating system.

Concrete Example

I am running an x86_64 system right now. This system does not know what C is. It does not know what OS X, Windows, or BSD are. It is ultimately running some x86_64 assembly code. That code was not written by humans (for most part). It was probably written by humans in C or C++ and translated into the assembly language. If I copy this compiled code on to my power PC machine it will not work. I need the original C/C++/whatever_language codebase and I need to translate that code to the power PC language. If I am trying something in C that is not translatable to power PC language then that feature will not work on the new operating system.

What about devices?

The more devices you plug into the machine (e.g., a monitor, a mouse, a printer, an audio output etc.) the more code you will have to write for the bridges. That is what the drivers do. You can write a driver in C if you want. All you need is a way to translate C into the "instruction set" of that device. Usually, it is easier to just embed some code/circuit into the device that reads standard electrical signals and trick the core computer into generating those electrical signals using the standard instruction set and device buses (e.g., USB).

What about bootstrapping?

Now of course, the operating system these days "ships" with the machine. And what people do is just install the code [compiled into the instruction set language of the machine] to some place where the machine can find it on its own. The trick is just to bootstrap the machine to find that code when booting it up. A JVM bootstrap example is below:

```<code>public final class Hello {
    public static void main(String[] args_) {
        System.out.println("Hello, World!");
    }
}

0000: cafe babe 0000 002e 001a 0a00 0600 0c09  ................
</code>```

What about… ?

Please see Tanenbaum or ask another question.

Title: Is it possible to write an operating system in C?

Body:
A while back I saw a comment on a Stack Overflow question that surprised me:

No one can write an operating system in C. It is not possible. What
  one can do is write an operating system in a C-based/C-like language
  that adds/defines a considerable amount of non-standard capabilities
  on top of C core.

Is it useful to define C so narrowly? People say Linux, or a GPU driver, or an embedded system was "written in C", not "written in C-with-some-extensions-to-accommodate-the-hardware."

Is it incorrect to do so?

Body:
The question is quite broad and as it stands the answer is yes. In fact, the answer is yes for most programming languages but there is a catch.

You need to translate your OS code into something that the machine understands. And it is the machine and its native language and your capability to translate from "your" language to the "native" language that would determine if you can write an operating system in your language or not.

General Theory

Let's say a machine has a lever. And only two things are possible -when the lever is pushed down the machine shall pour coffee and when pulled up the machine shall stop pouring coffee. Now imagine my native language translator is a human who can read C code printed on a paper and decide whether to push the lever up or down. So, for example upon reading the following line our human "compiler-linker" will push the lever down.

printf("pour coffee"); //Support more similar syntax in later versions!

And on reading the following line our human "compiler-linker" will pull the lever up.

printf("stop pouring coffee"); //Support more similar syntax in later versions!

We have successfully written an operating system for this coffee machine entirely in C. For that matter, we can train our compiler to translate Java, C#, KSH, Perl, English, Slavik, Sanskrit etc… and "operate" the machine. Hence the term, Operating System.

Of course most modern computers are capable of doing something more complex than this. And hence the complexity of their instruction set goes beyond just a simple lever state. These instruction sets will ultimately just put some transistors/magnets/LEDs etc. in some state and we humans will interpret that as a result.

The problem hence becomes one of manipulating this machine to achieve the states we want. And if your language (e.g., C) can be translated into that native instruction set and if you can use this bridge to make the machine do what you want then you shall have a successful operating system.

Concrete Example

I am running an x86_64 system right now. This system does not know what C is. It does not know what OS X, Windows, or BSD are. It is ultimately running some x86_64 assembly code. That code was not written by humans (for most part). It was probably written by humans in C or C++ and translated into the assembly language. If I copy this compiled code on to my power PC machine it will not work. I need the original C/C++/whatever_language codebase and I need to translate that code to the power PC language. If I am trying something in C that is not translatable to power PC language then that feature will not work on the new operating system.

What about devices?

The more devices you plug into the machine (e.g., a monitor, a mouse, a printer, an audio output etc.) the more code you will have to write for the bridges. That is what the drivers do. You can write a driver in C if you want. All you need is a way to translate C into the "instruction set" of that device. Usually, it is easier to just embed some code/circuit into the device that reads standard electrical signals and trick the core computer into generating those electrical signals using the standard instruction set and device buses (e.g., USB).

What about bootstrapping?

Now of course, the operating system these days "ships" with the machine. And what people do is just install the code [compiled into the instruction set language of the machine] to some place where the machine can find it on its own. The trick is just to bootstrap the machine to find that code when booting it up. A JVM bootstrap example is below:

public final class Hello {
    public static void main(String[] args_) {
        System.out.println("Hello, World!");
    }
}

0000: cafe babe 0000 002e 001a 0a00 0600 0c09  ................

What about… ?

Please see Tanenbaum or ask another question.


问:
Good practice for object instantiation in MVC
In MVC the Domain Models(from Model Layer) should instantiate other Domain Models or all the Domain Models should be instantiate in the controllers and passed down using Dependency Injections?

How do you implement this in real applications? If you choose this path isn't the controller getting to fat?

答:
In standard MVC Models should not know anything about other Layers, including other Models.
It is the job of Controller to instantiate them.

Unfortunately, the link to "Service Layer" provided in the other answer only leads to a very sketchy outline, directing the reader to the book for more details. In fact, I could not find a good detailed information on it, so maybe the concept is not so widely used?
But from what I see, it just looks like another kind of Controller, maybe of higher hierarchy, that orchestrates other Controllers.

You can write a dedicated Controller to instantiate all your Models, or it it gets too large, add individual Controllers for certain Models.


问:
What are the reasons to create UIView subclass?
I've noticed that there are a lot of UIView subclasses in my legacy project. Mostly the only reason of such a subclass is to split bigger view into custom subviews and provide layout for its subviews and delegation of UIButtons actions through the view delegate protocol. So I'm wondering, is it a correct design?  </p>

答:
A very common reason to create a UIView subclass is so that one can specify a drawRect method to do some Core Graphics drawing into a view.  Another reason might to implement touch delegates, such as if you want to do something within a specific view area too specialized for a gesture recognizer.

Partitioning objects (such as views) into logical groupings, possibly into a hierarchy, is usually considered good coding practice, as it helps isolates the scope of any changes or bugs.


问:
What justifies the use of an IDE versus a standard editor?
I find myself using my text editor of choice (vim, nano, gedit, pick your poison) much more often than any IDE as of late.

After noticing my ide shortcuts getting dusty I started to think about this and wonder: what justifies use of an IDE for you opposed to a text editor?

For that matter what rationale would you have for not using an IDE and merely relying on an editor?

答:
I use the IDE for testing / debugging / integration and KEDIT for editing because the IDE is seriously deficient in editing capabilities.

Because the .NET IDE recognizes external edits, all I need to do is save in the editor and accept the prompt to reload the source. This allows me to optimize my editing and debugging capabilities at the same time.

For other IDE's I use KEDIT as a template processor and source search program and copy / paste that source into the IDE.


问:
Can I create and publish an iPhone app by building it in a second hand Mac?
I have never published an app to app store.
I have a chance to buy an apple mac from someone.

Is it possible to use that to publish to app store? What if the first owner was also a developer?

If I buy Mac with the only intention of publishing an app should I only go for a new one to get developer license or I can do it in a second hand Mac also?

答:
The most current and best supported versions of Xcode for developing iPhone apps often requires a Mac that runs the latest released version of OS X, currently Mountain Lion 10.8.4.  Make sure the Mac meets the system requirements if this OS is not installed already.

You can delete the previous users keys and certificates from a used Mac.  After paying Apple $99/annum to enroll in the iOS Developers program, you can install your own certificates and provisions, perhaps in a brand new clean User account.


答: Why not creating an abstraction of your interface that can be specialised to each of the frameworks? I would write my own cacheing Controller with methods I need, that would encapsulate both caches. Then I can forget about them and only talk to my Controller. Any problems with that solution?</p>

Title: Two components offering the same functionality, required by different dependencies

Body:
I'm building an application in PHP, using Zend Framework 1 and Doctrine2 as the ORM layer. All is going well. Now, I happened to notice that both ZF1 and Doctrine2 come with, and rely on, their own caching implementation. I've evaluated both, and while each has its own pro's and cons, neither of them stand out as superior to the other for my simple needs. Both libraries also seem to be written against their respective interfaces, not their implementations.

Reasons why I feel this is an issue is that during the bootstrapping of my application, I have to configure two caching drivers - each with its own syntax. A mismatch is easily created this way, and it feels inefficient to set up two connections to the caching backend because of this.

I'm trying to determine what the best way forward is, and would welcome any insights you may be able to offer.

What I've thought up so far are four options:

Do nothing, accept that two classes offering caching functionality are present.

Create a Facade class to stick Zend's interface onto Doctrine's caching implementation.

Option 2, the other way around - create a Facade to map Doctrine's interface on a Zend Framework backend.

Use multiple-interface-inheritance to create one interface to rule them all, and pray that there aren't any overlaps (ie: if both have a "save" method, they'll need to accept params in the same order due to PHP's lack of proper polymorphism).

What option is best, or is there a "None of the above" variant that I'm not aware of?


问:
Whats the real overhead of TDD once the entire team is used to it?
What percentage of time is saved and costed doing TDD.

I assume this percentage of cost and reward changes during a projects life-cycle.

I'd imagine the initial phase has a lot more cost but little rewards attached. Further on (during re-factoring) you get the benefit of your tests.

I've heard anywhere from 30-50% of your time is writing unit tests. However that doesn't take into account the time saved from writing those tests. Whats the time saved as well as the time cost? In bug fixing and refactorablity?

答:
TDD is often measured towards code quality rather than time and cost spent. However, with better code quality, developers and any people working with them can work better (less time spent, less cost involved, happier, etc.). http://davidlongstreet.wordpress.com/2009/04/29/new-software-metric-wtfs-per-minute/

Writing tests is great for helping to automate verification of functional and non-functional requirements. One video that convinced me to adopt TDD (actually BDD, high level TDD):
http://video.google.com/videoplay?docid=8135690990081075324#

Writing functional tests can help spotting bugs/problems earlier during development phase. Assume you have large code base. With unit tests/specs, you only need to see "All tests passed"/"2 tests failed, see line xyz". You only need a team of developers to do both developing and testing. Without unit tests/specs, you have to manually compare printed statements with expected statements, and manually trace which methods/classes have bugs. You probably need two separate teams (developers and testers) to do this.

Written tests help developers explain progress and problems faced.

TDD helps fulfilling maintainability, adaptability, and flexibility of code. It encourages developers to write small testable chunks, and put them together into bigger testable chunks. The other way round (part of refactoring practice) also works, with condition that we have written solid tests. As a result, we can have nicely-written, modular code.

With TDD, we are glad to know when:

a customer requests changes on requirements (satisfying requirements)

better ways of writing code are discovered

team mates have suggestions for code improvement

we have to explain/pass our code to other people

TDD can be boring because development process takes small steps, and thus it becomes so predictable.


问:
Is Clojure development required to be open-source?
This question could be generalized to any language where the language development is open-source, potentially, but I'm most curious about Clojure specifically.

If Clojure (as a language) is open-source, licensed by the Eclipse Public License, which per this GitHub side-project requires derivative works to disclose source, must any application written in Clojure be distributed with source? Or must only derivative language projects (e.g. Continjuation or something) disclose the source?

Or do I have a faulty major premise somewhere in there?

答:
There are two major faults in your reasoning.

First, a language is a set of ideas and is not subject to copyright as such. Copyright would apply only to the language's specification document, translators and standard library implementations. Of these, only the library (and to a small extent the translator) can have an effect on the licenses you can use for programs written in that language.

This influence is limited in the sense that, if the library uses a strong copyleft license (like GPL), then the programs using that library must effectively be distributed under the same license. If the library is not strong copyleft, then you can choose any license you want.

Secondly, the Eclipse Public License is not copyleft and does not require the disclosure of source code for independent, separate modules. The license text uses the term "Program", but defines that term to mean "the code covered by this license." That means that the term "Program" does not have its normal English meaning, but is also used for things that we would normally call a library.

Essentially, the Eclipse Public License only requires you to disclose your source code if you make modifications to a program/library that is already covered by the Eclipse Public License. If you write a separate program that uses a library (which is covered by the Eclipse Public License), then you don't have to disclose the source code for your program, as it is a separate entity from the library.


问:
Should user stories be assigned to team members?
We are using JIRA to manage the scrum process. What I'm curious about is whether the User Story issue type should be assigned to a team member, the PO, or remain unassigned. My gut tells me it should remain unassigned to be assigned to the PO since the team should only be working on Task issues, but I wanted to see if I'm missing anything.</p>

答:
There is no hard and fast rule about assigning User Stories within the tool of your choice (some tools may not even support it). It all comes down to how you are using your tool.

If you are using the User Story items merely as a container for Task items, without any defined states or transitions, then it is most logical to leave the User Stories unassigned.

It you transition the User Story items from Open to In Progress to Done along with the Tasks they contain, then you might assign the User Story to the person responsible for keeping the User Story state consistent with the states of the underlying Tasks (which can even be the scrum master), or you can leave it unassigned if that is a team responsibility.


答:
In .NET context, MVC is a framework for building websites.

M(Model) refers to a viewmodel, i.e. it's a data structure that will be used specifically for display purposes. Examples of view models:

DisplayCustomerViewModel - data structure that has everything required for displaying customer information

DeleteCustomerViewModel - data structure that has everything required for removing customer (probably id and customer name for confirmation purposes).

View models are different to your domain model. If you don't understand it, then read it again and do some research.

You shouldn't use your domain models instead of view models, period.

If you view model and domain model are the same (for now anyway), then just copy data from domain model into view model (use auto mapping framework to save you time).

V(iew) refers to a page that should have a dependancy on your view model (M). Its sole purpose is to display data stored in that view model.

C(ontroller) in my eyes should:

Call a business layer to get data or update data. See example below.

Business layer should then return a result of the operation.

Controller takes the result and maps it to the view model.

Controller decides whether to simply display view model, re-direct user or do something else.

At no point controller should be doing any business logic.

Ideally, you should not reference the domain layer in your MVC project (presentation layer) at all. This way you won't confuse domain models with view models.

Example of what I consider to be a good controller action:

```<code>public ActionResult UpdateCustomer(UpdateCustomerViewModel updateCustomerViewModel)
{
   if (!ModelState.IsValid)
      return View(updateCustomerViewModel);

   // I create a DTO that holds customer information necessary to do the update. I copy values from my view model to my DTO object.
   var updateCustomerDTO = AutoMapper.Map<UpdateCustomerDTO>(updateCustomerViewModel);

   // I have a command that encapsulates customer update logic. This command
   // is in a business layer and it knows nothing about view models.
   // Dependency is a static class that exposes IoC container.
   // normally I would set my commands through constructor though.
   var updateCustomerCommand = Dependency.Resolve<IUpdateCustomerCommand>();

   // When command executes, it produces a result. Result may be as simple as
   // true (success) and false (failure). I however chose to have a custom
   // type representing a result of the command.
   var result = updateCustomerCommand.Execute(updateCustomerDTO);

   // Self explanatory
   if (result is SuccessfulCustomerUpdate)
      return Success();

   return Failure();
}
</code>```

Just to recap the flow:

View model is mapped to DTO

DTO is passed to the business layer

Business layer extracts data from DTO and does some work by talking to domain layer (Domain models)

Business layer sends back DTO or some kind of result object

Presentation layer takes data out of DTO or result object and maps it to the view model

Presentation layer displays the view model

Title: Good practice for object instantiation in MVC

Body:
In MVC the Domain Models(from Model Layer) should instantiate other Domain Models or all the Domain Models should be instantiate in the controllers and passed down using Dependency Injections?

How do you implement this in real applications? If you choose this path isn't the controller getting to fat?

Body:
In .NET context, MVC is a framework for building websites.

M(Model) refers to a viewmodel, i.e. it's a data structure that will be used specifically for display purposes. Examples of view models:

DisplayCustomerViewModel - data structure that has everything required for displaying customer information

DeleteCustomerViewModel - data structure that has everything required for removing customer (probably id and customer name for confirmation purposes).

View models are different to your domain model. If you don't understand it, then read it again and do some research.

You shouldn't use your domain models instead of view models, period.

If you view model and domain model are the same (for now anyway), then just copy data from domain model into view model (use auto mapping framework to save you time).

V(iew) refers to a page that should have a dependancy on your view model (M). Its sole purpose is to display data stored in that view model.

C(ontroller) in my eyes should:

Call a business layer to get data or update data. See example below.

Business layer should then return a result of the operation.

Controller takes the result and maps it to the view model.

Controller decides whether to simply display view model, re-direct user or do something else.

At no point controller should be doing any business logic.

Ideally, you should not reference the domain layer in your MVC project (presentation layer) at all. This way you won't confuse domain models with view models.

Example of what I consider to be a good controller action:

public ActionResult UpdateCustomer(UpdateCustomerViewModel updateCustomerViewModel)
{
   if (!ModelState.IsValid)
      return View(updateCustomerViewModel);

   // I create a DTO that holds customer information necessary to do the update. I copy values from my view model to my DTO object.
   var updateCustomerDTO = AutoMapper.Map<UpdateCustomerDTO>(updateCustomerViewModel);

   // I have a command that encapsulates customer update logic. This command
   // is in a business layer and it knows nothing about view models.
   // Dependency is a static class that exposes IoC container.
   // normally I would set my commands through constructor though.
   var updateCustomerCommand = Dependency.Resolve<IUpdateCustomerCommand>();

   // When command executes, it produces a result. Result may be as simple as
   // true (success) and false (failure). I however chose to have a custom
   // type representing a result of the command.
   var result = updateCustomerCommand.Execute(updateCustomerDTO);

   // Self explanatory
   if (result is SuccessfulCustomerUpdate)
      return Success();

   return Failure();
}

Just to recap the flow:

View model is mapped to DTO

DTO is passed to the business layer

Business layer extracts data from DTO and does some work by talking to domain layer (Domain models)

Business layer sends back DTO or some kind of result object

Presentation layer takes data out of DTO or result object and maps it to the view model

Presentation layer displays the view model


答:
It really does not matter unless

you have given a certain meaning to the assignee field (within the Scrum team's workflow) - e.g. assignees check definition of done before passing story to PO

you are passing along the issue through certain stages (as part of a bigger workflow, e.g. from team to team with one respective team lead as the assignee)

Remember that in addition to the assignee field you also have certain statuses. Typically, I would say that the status is enough and that an assignee is not necessary, but you might feel that this is better suited to your needs. Both can achieve the same thing.

Title: Should user stories be assigned to team members?

Body: We are using JIRA to manage the scrum process. What I'm curious about is whether the User Story issue type should be assigned to a team member, the PO, or remain unassigned. My gut tells me it should remain unassigned to be assigned to the PO since the team should only be working on Task issues, but I wanted to see if I'm missing anything.</p>


答:
Historically, IDEs provided unmatched convenience on a single-tasking computer.  My first C compiler required the following steps in the edit-compile-run cycle:

Start editor

Edit program

Save program, quit editor

Compile program

Assemble compiled program

Link compiled and assembled program

Run program

on my CP/M system.  (I could have automated much of that as a batch program had my disk drives been larger.)

When I got Turbo Pascal, I was delighted to be able to keep the editor available while compiling and debugging.

That, I believe, is what made IDEs popular in the first place.

Title: What justifies the use of an IDE versus a standard editor?

Body:
I find myself using my text editor of choice (vim, nano, gedit, pick your poison) much more often than any IDE as of late.

After noticing my ide shortcuts getting dusty I started to think about this and wonder: what justifies use of an IDE for you opposed to a text editor?

For that matter what rationale would you have for not using an IDE and merely relying on an editor?


问:
How to create own programming language based on JVM?
I am curious about how to create a programming language based on JVM so I have tried to get some info online, but the information I got are quite fragmented.  What I found are mostly information related to single technologies like ASM, Eclipse JDT, JFlex, etc, but what I would like to know are the main steps that need to be implemented and suggested technologies for these steps.

Any idea?

Well this question sounds quite broad but I started to think that is not like that. I kept looking up information online and you can get (relative easily) a basic customized language just using ANTLR (or alternative like JavaCC) used by Groovy mixing it with ASM (alternative BCEL or same Javac compiler). The first helps you to build the necessary grammar/parsing/AST and the second to generate the final bytecode once you got a successful parsing.

BTW from the same author of ANTLR I found this book that more and less is what I was looking for:

http://pragprog.com/book/tpdsl/language-implementation-patterns

答:
1) specify a grammar for your language

2) write or generate code that parses to that grammar

3) build an abstract syntax tree

4) perform optimisations (optional)

5) compile to JVM bytecode. The JVM spec is here


问:
How many ALU additions are needed to add three numbers?
Please give reasons for your answer.

As I found, two additions are needed.
This is because every number to be add needs to changed to binary. Then addition is done between two binary numbers where the XOR gate is used for addition. When a carry bit is required an AND gate is involved to add the carry bit to the next line.
Therefore if more than 3 binary numbers are added together there can be more than one carry bit and the AND gate doesn't support that.

Am I right or I am confusing everything and nothing make sense?

Thank you for your time.

答:
The answer is "it depends," because the question is ambiguous as worded.

As you observed, you can add any two numbers (which I'll define as "unsigned and will fit in a CPU register") and get away with a single carry bit because that's as much as you need for adding the two largest possible values.  In an 8-bit world, adding 0xFF and 0xFF will net you 0x1FE, a value larger than a register will hold, which is why CPUs have carry bits.  Add an additional large value (0x1FE + 0xFF) and you're into 0x2FD, which requires a second bit of carry you don't have.  This is where you quit fooling around with a single carry bit and use an entire register to count carries instead.   This gives you the 16-bit number you need to hold the result.

Here's a bit of assembly for the 6502, an 8-bit CPU designed in the 1970s, that demonstrates how this is done.  We're using two of its registers, X to hold the upper bits and A to hold the lower bits of the 16-bit result.  We'll also go on the assumptions that we're writing code to add three numbers we know ahead of time and we're not doing anything fancy to save space.

```<code>        ; Preparation
        LDX  #0      ; Clear the high-order bits by loading zero into X.
        LDA  #11     ; Load first number directly into A, no add required.
        CLC          ; Clear the carry flag.

        ; Adding of second number
        ADC  #22     ; Add the second number to A, with carry.
        BCC  THIRD   ; If carry is clear, no overflow.  Branch to THIRD
        INX          ; Carry was set, increment the high-order bits.
        CLC          ; Leave the carry flag clear before the next addition

        ; Adding of third number
THIRD:  ADC  #33     ; Add the third number to A, with carry.
        BCC  THEEND  ; No carry.  We're done.
        INX          ; Carry was set.  Increment the high-order bits.

THEEND: RTS          ; Return with the 16-bit result in X and A.
</code>```

If the constants (11, 22 and 33) can be any number, the worst case is that you execute two ADC and two INX instructions for a total of four uses of the ALU.  Best case is no carries, which means only two additions.  You'll notice that there are only two additions and not three, because the first is always added to zero and can therefore be loaded directly into a register without using the ALU.

In a more general-purpose routine, you'd start by zeroing out your accumulated 16-bit number and having to use the ALU once (no carry) or twice (carry) per addition.  The worst case for adding any three numbers becomes six and the best case is three.

Body:
The answer is "it depends," because the question is ambiguous as worded.

As you observed, you can add any two numbers (which I'll define as "unsigned and will fit in a CPU register") and get away with a single carry bit because that's as much as you need for adding the two largest possible values.  In an 8-bit world, adding 0xFF and 0xFF will net you 0x1FE, a value larger than a register will hold, which is why CPUs have carry bits.  Add an additional large value (0x1FE + 0xFF) and you're into 0x2FD, which requires a second bit of carry you don't have.  This is where you quit fooling around with a single carry bit and use an entire register to count carries instead.   This gives you the 16-bit number you need to hold the result.

Here's a bit of assembly for the 6502, an 8-bit CPU designed in the 1970s, that demonstrates how this is done.  We're using two of its registers, X to hold the upper bits and A to hold the lower bits of the 16-bit result.  We'll also go on the assumptions that we're writing code to add three numbers we know ahead of time and we're not doing anything fancy to save space.

        ; Preparation
        LDX  #0      ; Clear the high-order bits by loading zero into X.
        LDA  #11     ; Load first number directly into A, no add required.
        CLC          ; Clear the carry flag.

        ; Adding of second number
        ADC  #22     ; Add the second number to A, with carry.
        BCC  THIRD   ; If carry is clear, no overflow.  Branch to THIRD
        INX          ; Carry was set, increment the high-order bits.
        CLC          ; Leave the carry flag clear before the next addition

        ; Adding of third number
THIRD:  ADC  #33     ; Add the third number to A, with carry.
        BCC  THEEND  ; No carry.  We're done.
        INX          ; Carry was set.  Increment the high-order bits.

THEEND: RTS          ; Return with the 16-bit result in X and A.

If the constants (11, 22 and 33) can be any number, the worst case is that you execute two ADC and two INX instructions for a total of four uses of the ALU.  Best case is no carries, which means only two additions.  You'll notice that there are only two additions and not three, because the first is always added to zero and can therefore be loaded directly into a register without using the ALU.

In a more general-purpose routine, you'd start by zeroing out your accumulated 16-bit number and having to use the ALU once (no carry) or twice (carry) per addition.  The worst case for adding any three numbers becomes six and the best case is three.


问:
What are the pros and cons of the MVVM architecture?
In class today we were introduced to the MVVM architecture for Silverlight/WinPhone/WPF; it looks nice for big projects, but what are your thoughts on MVVM?

What are the pros and cons?

I want to get more into the architecture so that I know when I should use it.

答: The thing I like most about MVVM (besides the test-ability), at least from a web UI perspective, is that I don't have to write a bunch of plumbing code to wire-up all my event handlers to the page...  It's also much easier to think in terms of behaviors and distinct units of responsibility when using this approach.</p>


问:
Is it safe to transmit access tokens via HTTP headers?
It's the first RESTful web service and I am concerned about security issues. Is it safe to transmit my access token via HTTP headers? For example:

```<code>POST /v1/i/resource HTTP/1.1
Content-Type: application/x-www-form-urlencoded
Api-key: 5cac3297f0d9f46e1gh3k83881ba0980215cd71e
Access_token: 080ab6bd49b138594ac9647dc929122adfb983c8

parameter1=foo&parameter2=bar
</code>```

The connection made over SSL. Also, What is need to be defined as the scope attribute for every access token

答:
There are no serious issue in transferring access token over http headers because transferred data is encrypted when SSL is used, means it can be understand only by particular client which made that request and server who responses for the request, in between there are no chances to understand the data by any third party.

Other thing is access token are time based so they have a life for a specific period so they have no chances of use in future.


问:
BitBucket working with multiple developers on same project
I am new to BitBucket. I have my repository. And 2 people working on it me, Admin and another developer with Read only access.

So in order for him to do changes he forked repository and made changes, uploaded to his repository and created pull request.

Now I merged this pull request with my repository. And made few small changes afterwards and also committed them and uploaded to my repository.

What would be the next step for him to continue working? Does he have to fork it each time I make changes to my repo?

Is there some way for him to sync his with my repository without creating new fork each time?

答:
This is and old question, but just for the sake of including an answer:

Your developer will notice in his forked repository a message saying that new changes has been included in the main repository (your repository), and he can merge those changes very easily.

The meessage is something like: This fork is XX commits behind  "Sync now".

Best regards,


答:
the important long-term measures are not only code quality and code confidence, but even moreso not burning out the team doing mindless testing

the short-term measures would be the ROI of automating the tests

for example: last week I made over 1000 code changes due to an internal-architecture shift, started the automated test suite, and went to sleep.

the tests took 28 minutes to run; they all passed. manually performing the same 40+ acceptance tests would take about 6 hours.

another example: in a prior iteration i had goofed up one of the test scenarios with a subtle bug that manual testing probably would not have found (the automated tests perform db integrity checks that manual testers almost never do). i had to run that test scenario about 50 times before i managed to figure it out and fix it. manually performing the test scenario operations would take about 50 minutes. So that's 41.6 man-hours of labor saved in one day

there is no way of calculating in advance the ROI of automated testing, because you cannot know exactly how many times you will need to run the tests.

but to me, the ROI of automated tests is nearly infinite

Title: Whats the real overhead of TDD once the entire team is used to it?

Body:
What percentage of time is saved and costed doing TDD.

I assume this percentage of cost and reward changes during a projects life-cycle.

I'd imagine the initial phase has a lot more cost but little rewards attached. Further on (during re-factoring) you get the benefit of your tests.

I've heard anywhere from 30-50% of your time is writing unit tests. However that doesn't take into account the time saved from writing those tests. Whats the time saved as well as the time cost? In bug fixing and refactorablity?


答:
I think it all depends on your team and the problems your team is trying to overcome.

If your team is having trouble completing user stories, or if you find the user story's tasks drift away from the text, then yes have a story assigned to someone. It will be the story owner's responsibility to ensure tasks meet the goal of the story, all tasks are done-done, and the sum of all tasks completes the story.

If your team doesn't have a problem completing user stories, then why bother? Don't use process as a straitjacket; use process as a tool to solve problems.


问:
Python dynamic attributes creation, a blessing or a curse?
Consider this code:

```<code>>>> class Foo():
        pass
...
>>> foo = Foo()
>>> foo.a = 'test'
>>> foo.a
'test'
</code>```

One can just override __setattr__ to make attributes read only and prevent their creation at runtime, however:

Why is this the default Python behavior (any good reasons)?

Is there any practice to prevent this without altering each class?

Would you worry about this behavior in serious projects? don't you consider it error prone? or you can just ignore it (relying on new IDEs code completion)

答:
Would you worry about this behavior in serious projects? don't you
  consider it error prone? or you can just ignore it (relying on new
  IDEs code completion)

Yes, I worry. To me, it is not clear from the post whether you are pointing to the dangers of allowing outsiders to reason about and change the structure of the objects, or to the dangers of assigning to a previously undefined attribute. However, both behaviors are known to be problematic (the first, for sacrificing the benefits information hiding techniques bring to the table and relying on convention; the latter for allowing the spreading of definitions of structure/object when it is desired to have them locally organized).


问:
Best way to quickly explore/grok open source C/C++ projects?
I'm looking for a suggested workflow for quickly being able to download various c/c++ open source projects and then begin intelligently navigate sources.

"Intelligently" means being able to jump around  to usages, definitions, implementations of a particular symbol, both in the downloaded code base, and also the headers of referenced libraries perhaps installed in /usr/local or /System/Frameworks etc.

this code jumping could be  driven by etags, ctags, gnu global, eclipse CDT indexer, Xcode's indexer, I'm open to anything, but I have no idea what is the best solution for most cases out there.

Shortly afterwards I would like to begin stepping through unit tests, examples, demos in the debugger so I can better grok how the code works

Obviously, this isn't going to be possible for every project out there.. but most of the projects I am interested in are either autotools or cmake based -- In general, I don't really care what IDE (emacs, vim, xcode, eclipse, etc) I use, and I don't mind running a command line debugger -- I just want to quickly download a C/C++ project, "fool around with it" at a source level, and then move on if its not interesting.

My question is particularly directed to the guy or gal super hacker who routinely explores several different large C/C++ projects every few days/weeks -->  how do YOU productively do this?

(My background/experience level is that I know enough about c/c++ tooling to get things to build/or debug a broken build on several different os'es usually within a few minutes, but it can take hours before I get to the point where I can take a large project  and get to the point where I am stepping through examples in the debugger. I have a feeling this is because I try to use modern IDE's, but I'd be better of just using 'old school' tools. when dealing with jvm stuff -- it is usually pretty quick to get to a place where one can get intellij to grok code and start debugging -- I'd like to replicated this as much as possible in C/C++)

thanks!

答:
Follow the money. And by money I mean data. And of course take advantage of intelligent naming conventions and comments as you go (if there are any). In truly rotten codebases simply searching for references and the flow of passed/returned params often helps me more than IDE features. In well-structured code, I often find setting breakpoints and stepping through given sections of it is a great way to get an early idea of how it all works. This is less helpful when the code is completely bat!@#$ and is more likely to result in a migraine.

Oddly enough the exact opposite seems true when debugging. You can often simply examine references to figure out where a problem is in clean/well-structured code whereas the only way to find a problem in a complete disaster is to walk through all umpteen dozen calls of complete tomfoolery until you see where it's breaking.


答:
If you were to transmit access token header through HTTP, then it would be vulnerable to the man-in-the middle attack.

When you transmit access token header through HTTPS, then nobody apart from the client will be able to see this token as the request will be tunnelled through secure connection.

Title: Is it safe to transmit access tokens via HTTP headers?

Body:
It's the first RESTful web service and I am concerned about security issues. Is it safe to transmit my access token via HTTP headers? For example:

```<code>POST /v1/i/resource HTTP/1.1
Content-Type: application/x-www-form-urlencoded
Api-key: 5cac3297f0d9f46e1gh3k83881ba0980215cd71e
Access_token: 080ab6bd49b138594ac9647dc929122adfb983c8

parameter1=foo&parameter2=bar
</code>```

The connection made over SSL. Also, What is need to be defined as the scope attribute for every access token