Programming Theory

Programming theory deals with the design, implementation, analysis, characterization, and classification of programming languages and their individual features, along with introductory programming concepts like program structure, variable declaration and conditional and looping constructs. Sub-disciplines include the formal semantics of programming languages, type theory, program analysis and transformation, comparative programming language analysis, metaprogramming, domain-specific languages, compiler construction and run-time systems.

C#: Please explain relationship between "async" and "await"

I generally see how this code works:

but need a better understanding of when to use both "async" and "await" together. I was a little confused by the transition of one paradigm to the the better paradigm in this one, a simple explanation would be helpful.

Hi Experts,

Wondering if there is a site or program that will translate a code snipped into plain English?
The way it has to convert it into computer language (binary format 0001011100) , it should be something for ordinary people (beginners) too...

Something like the following

//hide default submit button row at the bottom of inline forms
$(document).ready( function() {
    $( '.cb-hide-submit input[type="submit"]' ).closest( 'tr' ).remove();
    $( '.cb-btn-reset' ).bind('click', function() {
        $( this ).closest( 'form' ).find( 'select, input[type="text"]' ).val( '' );
        $( this ).closest( 'form' ).submit();
    $("form").on(":submit", function(event) {
        if(!checkBrowser()) {

Open in new window

Where could I see what each line of code is supposed to do?

PS. If there is a converter from JQuery to VBA that would also be helpful (in my case).

I wonder, given some program source code, and applying small incremental refactorings, is it always possible to get from any starting code to any other code configuration where the code still retains all the functionality of the original code, or are there valid code configurations which cannot be achieved through refactoring?

For example, starting with code which sorts using Bubble Sort, is it possible to refactor that using small incremental refactorings and end up with a much better sorting algorithm, such as Heapsort or Quicksort?

(I suspect not. I suspect the only way to go from Bubble Sort to Heapsort would be to first analyze the Buble sort code and realize on a higher level what the code is achieving, namely that this bit of code is a "Sorting Algorithm", and then one can replace that sorting algorithm with any other sorting algorithm, but the swap I'm guessing consists of fully replacing the algorithm with a different algorithm which accomplishes the same thing; I'm guessing there are no smaller incremental refactoring steps that could be made without understanding the higher concept of what the code is trying to achieve.)

Is my hunch correct? Has any mathematician examined this to prove what better code configurations are reachable and which ones are not, by using only standard refactoring techniques, without understanding the "goal" of the code?

(I'm kind of fudging because I'm sure someone will say "replace one algorithm with a better one" is a …
Question about AI technologies to solve this "learning" challenge

I am new to AI and have had no real experience coding anything related to Natural Language Processing. But, I am eager to jump in!

I need to find a method that I can find the following two options have a high match:

#1 Frank's First Car was a Red Chevy

Frank has never had more than one car
Frank would only buy a red car
Frank comes from a family that only buys Chevy's

Frank has never owned a car

Are there a combination of AI technologies which can:
1) parse these statements
2) preserve them in some fashion
3) Allow them to be organized such that the comparison between #1 vs. #2 returns a very high match (90+%) versus #2 vs. #3

I am interested to see if such tool and languages exist for this.

Moore's Law and IBM's Summit

Does anybody have a recent chart  that would confirm or refute Moore's Law which says that "the number of transistors in a dense integrated circuit doubles about every two years."

Is it faster? Has that rate increased? Held steady? Or is it in decline?

And I wonder about is there were some similar measure of processing power from a super-computer that would help us see the growth in processing power over time?

Hello all,
It's strange that I Google searched and found no answer because even Microsoft has asked their community for opinions on changing this sometimes confusing initialism.

SDL = Secure Development Lifecycle
SDLC = Software Development Lifecycle (supported by Microsoft)

But my question is really about what are the differences between the two lifecycles? That is the question that I was surprised not to easily find in a Google search. It's like I am the first person, ever, to ask this question. LOL

I think I know the difference, but I don't want to influence my thoughts in this question.

Thank you. :)
In short, one company is saying another company has stolen source code.  

I have been independently contracted to make this determination.
My first thought was to do a text compare via command line.  However, I wanted to reach out to the community to see if there are any suggestions.   I know I can write something myself to do this, but I was curious if there was anything “off the shelf” that I could use to assist.

Any suggestions would be greatly appreciated.
I am developing an Electronic Medical Records application which should connect to medical equipment to get the data emitted by this equipment and save it to database.

The equipment also prints the data on a paper.

How can I design a solution by which if the connection from the computer to the equipment is lost, the doctor should be able to enter the data on the paper to the GUI of the App.
What are the common patterns for distributed software architecture? Is there any list?
I have this bit of C Code for a project I working on for a project.  
logit("Username: %s Password: %s", authctxt->user, password);

Open in new window

This is going to be used in a proof of concept project and I want to obscure the real password.  I was thinking of either replacing the whole password with a set of characters or maybe keeping the first and last two characters and replacing the rest with a set of characters.  Maybe Xs.   Looking for suggested modification.
I have an application which implements a state machine based on StateForge (StateBuilderCpp) generator. A state machine is defined as asynchronous and uses boost in the generated code:

<settings asynchronous="true" library="boost">

Open in new window

Actions (implemented methods) are very fast but are called frequently - events are triggered with 10ms intervals. State machine uses boost ioservice.

I run the application on a single core atom processor. Generally that pc is strongly utilized by others applications and I have noticed that sometimes when a cpu has a high iowait a dozen or so events are queued. Is it coincidence ? How to explains such behaviour ?
Is SOLID Outdated?

What are more modern definitions/terms for design principles for OOP?

I am currently studying software development at a university part-time. I also have to learn UML which I am having difficulties with because I cannot see any vocational relevance.
Where I work, we work agile and I was told that we do not have time to draw diagrams for hours and then make changes to it whenever the code changes.

Does anyone still use UML or is it only used in academia; that is: in research, study etc..

I assume that UML was used when working in the "waterfall model"?
Does anyone know of good software design application? Something I could use to visualize the logic of my php scripts before coding?
How much effort do you Experts think should go into defensively 'protecting' a text input field (which will be used to obtain key search terms for a text search) from (possibly) irrelevant input from the operator, such as too many space characters, punctuation and other tokens which might not be helpful to an effective search strategy ? I'm relatively ok with implementing methods that are considered helpful, so this is not a request for coding assistance, but rather about approach and real-life search term management and oversight. (I suppose another way of putting the same point it that I wish to avoid second-guessing the inputter whose attempts may well be valid, but look odd in plain discrete standalone terms. Thanks for any suggestions along these lines.
Explain Big O notation, Binary Search and Logarithms, C#

I am curious to learn more about Big O, Binary Search and huge data sets.

What sorting and searching methods maximize performance for millions of records?

Is Binary Search still used here?

What happens if a thread acquires a lock (SemaphoreSlim), and then that thread gets terminated before it releases the lock?

private SemaphoreSlim semaphoreSlim = new SemaphoreSlim(1, 1);
public async Task DoStuff()
    using (semaphoreSlim.WaitAsync(1000))
    	...//Do something

Open in new window

What happens if the thread gets terminated while it's in "Do Something"?
Need to implement Spring Security for a project.


  Structure: User table, Permission table, Module table and PermissionGroup table
  User will have only one permission group.
  Permission table will have read/write/update etc.,
  Module will be product/sales/order
  Permission group table will be product - read/write, sales - read/write/update


 Structure: User table, Roles table, Permission table,
 User can have 1 role
 Permission table will have as product_read, product_write, sales_read, sales_write

Comments on Option2:

 We can able to use Spring hasRole() kind of configuration for each method and can associate a role to it.
 Drawback: We cannot have dynamic roles as we can able to do it option1

Comments on Option1:

We can have dynamic groups however we cannot use spring hasRole(). Instead we need to get the manual decisions based on the http request - PUT/GET/POST and check for the permissions configured and decide whether to allow the URL or not in the interceptor.


This may not be a standard practice
What would be the best approach out of this two as well as preferable one?

I'm new to C# Language.What is the best Design Patterns i need to follow.
I can understand it's depend on the project,According to yours experience what is the most recommended Design Patter?
We have a program that was originally a WinForms program. We converted it to WPF and MVVM. Problem is the VIewModel for the window is still 3000 lines. It's difficult to maintain because I'm always jumping around the file trying to find related parts.

I'm wondering if there's a better way to consolidate this, perhaps different parts could be split into different files.

The window has a toolbar, with several buttons on it, and a couple TextBoxes. There's buttons like Play, Pause, Stop, Open File, Save File, typical stuff. A couple textboxes users can enter times in.

The ViewModel has a Play command, a Pause command, a Stop command, an Open File command, a Save File command. There's a property for TextBox1, and a property for TextBox2. The properties send notifications when they are changed. Standard stuff.

It all just becomes a lot when it's all placed together in the same ViewModel file. Even worse, our coding standard dictates that all fields should go in one place, while all Properties go in another place, so whenever I look at a property, the corresponding field is somewhere else if I want to look at it.

If I'm trying to trace the Play button, for example, the ViewModel constructor sets up the PlayCommand. The PlayCommand variable however is defined elsewhere. The constructor just sets it. Then the Play() method it calls is elsewhere in the file, and the CanPlay method is elsewhere. And mixed in with this all is the code …
import org.json.simple.JSONObject;

class JsonEncodeDemo {

   public static void main(String[] args){
      JSONObject obj = new JSONObject();

      obj.put("name", "foo");
      obj.put("num", new Integer(100));
      obj.put("balance", new Double(1000.21));
      obj.put("is_vip", new Boolean(true));

On compiling and executing the above program the following result will be generated −

{"balance": 1000.21, "num":100, "is_vip":true, "name":"foo"}

Open in new window

what above example doing
is it encoding jsonobject to java object?
i see output also seems like json to me?
Following is another example that shows a JSON object streaming using Java JSONObject −

import org.json.simple.JSONObject;

class JsonEncodeDemo {

   public static void main(String[] args){
      JSONObject obj = new JSONObject();

      obj.put("num",new Integer(100));
      obj.put("balance",new Double(1000.21));
      obj.put("is_vip",new Boolean(true));

      StringWriter out = new StringWriter();
      String jsonText = out.toString();
On compiling and executing the above program, the following result is generated −

{"balance": 1000.21, "num":100, "is_vip":true, "name":"foo"}

Open in new window

how above one is differen from first one?
Consider algos/softwares that take keywords in one document and match them (possibly a kind of set intersection) with keywords in N other documents, possibly producing a match ranking.

a. Is there a specific name for this?
b. Are there implementations in Java and PHP?

Example use cases would be
  • patients submitting a list of symptoms and then software looking for matches against known conditions
  • applicants submitting skillsets and looking for potential job matches
  • dating websites
See this code:
$piece1 = $test;
$piece2 = "";
$piece3 = "";
$ln = strlen($test);
if ($ln > 84) {

	$arrayWords = explode(' ', $test);

// Max size of each line
	$maxLineLength = 84;

// Auxiliar counters, foreach will use them
	$currentLength = 0;
	$index = 0;

	foreach ($arrayWords as $word) {
    // +1 because the word will receive back the space in the end that it loses in explode()
		$wordLength = strlen($word) + 1;

		if (($currentLength + $wordLength) <= $maxLineLength) {
			$arrayOutput[$index] .= $word . ' ';

			$currentLength += $wordLength;
		} else {
			$index += 1;

			$currentLength = $wordLength;

			$arrayOutput[$index] = $word . ' ';
	$piece1 = $arrayOutput[0];
	$piece2 = $arrayOutput[1];
	$piece3 = $arrayOutput[2];

Open in new window

This works perfectly, except I need a variation where I can limit the FIRST line ($arrayOutput[0]) to 84 & the subsequent lines to 94. See attached image for visual of this need. The text is printed using a pdf generator on an existing form image (with the word Remarks & the lines.)

How can I do this?

Thank you
I was writing below example


import org.junit.Before;
import org.junit.Test;
import junit.framework.Assert;
import static org.mockito.Mockito.*;

public class CalculatorServiceTest {

	CalculatorService calService;
	public void setup(){
		ICalculator cal_mock = mock(ICalculator.class);
		when(cal_mock.add(2, 4)).thenReturn(6);
		calService=new CalculatorService();
	public void testAddNumbers(){
		Assert.assertEquals(6, calService.addTwoNumbers(2,4));

Open in new window


public class CalculatorService {
ICalculator cal;
public ICalculator getCal() {
	return cal;
public void setCal(ICalculator cal) { = cal;
public int addTwoNumbers(int x, int y){
	return cal.add(x, y);

Open in new window


public interface ICalculator {
public int add(int x,int y);

Open in new window

why we need setter for calservice implementation class.

why are they setting interface mock object to the calservice object

observerd one example here

i do not see any setter here though?
hi how to see post man response. i installed post man now instead of advance res client

Programming Theory

Programming theory deals with the design, implementation, analysis, characterization, and classification of programming languages and their individual features, along with introductory programming concepts like program structure, variable declaration and conditional and looping constructs. Sub-disciplines include the formal semantics of programming languages, type theory, program analysis and transformation, comparative programming language analysis, metaprogramming, domain-specific languages, compiler construction and run-time systems.