instruction
stringlengths
34
36.1k
I've recently been using some build tools for a Nodejs project at work when I realized that most languages' main build tool/system use a different language than the underlying programming language itself. For example, make does not use C or C++ to write scripts and ant (nor Maven) doesn't use Java as their language fo...
Let's say, hypothetically, I'm writing a Java compiler. And we assume that in my case a class can't be fully compiled until all signatures of dependencies (imports and other used classes) are known. Because I don't want to keep the source code and AST of all classes in memory at the same time, I'll need an algorithm to...
I am reading through an Algorithms book and am working through a recursive solution to the following question: Implement a function to check if a linked list is a palindrome This is an easy enough task, but the book suggests a recursive solution that I can't seem to wrap my head around. It states that to know when we...
This questions is related to this one : anonymous checkout My company bought a CRM software and I am concerned by the way it stores customers' information. The website allows anonymous users to have a shopping cart and add products. The website asks them to log in once they want to pay. The thing is: anonymous custome...
The problem: Documentation is in code in the form of docs, its in wiki websites, its written down on notes, in diagrams and issue management systems. When documentation is so spread out, how does one manage to keep it up to date and relevant?
As the title says, how can someone suggest a specification to the World Wide Web Consortium (w3c)? Is it even possible? Can someone at least suggest the w3c to have a discussion on the specifications suggested? Or is it done by the voting system, as in Area 51 of StackExchange? I did some googling but couldn't find any...
I'm trying to create a php website that users log into and they can submit data to a MySQL database. How do I make it so the users can only see data they've submitted and not everyone else's data? Should I use: Echo $_sessions[user][piece of data] Am I on the right track or is there an easier way to go about this? I...
I occasionally get conflicted when using a language that isn't Rebol (happens from time to time) and get to thinking, hm—would life be easier in Rebol if this thing worked this way? To illustrate my current instance, in Rebol you send a message as follows: send foo@bar.baz "A Message" It's always been one of the kille...
In the GNU Affero General Public License, there is a section that reads: The GNU Affero General Public License is designed specifically to ensure that, in such cases, the modified source code becomes available to the community. It requires the operator of a network server to provide the source code of the modifi...
I am just building a MVC .NET application, eventually this will use entity framework and the repository pattern to structure the program. The first release however will only be calling other jobs that run reports. For this I was going to make the interface iReport of which another project (that can call Matlab) will im...
Imagine a simple service architecture setup: single server where I have one service acting as a REST API (PHP), another service for rendering frontend (nodejs), and maybe a database service. They all communicate through localhost requests, so for example frontend gets data from API by calling http://localhost:{API PORT...
I'm pretty sure there is a special name for the 'spec' of a function/method. It's a word that refers to how many arguments it takes the order of arguments which arguments are optional Is there a name for that?
I could write an endless amount of debugging code to handle the various components of input for a function, check that the correct data types are used, make sure things are decendants of the proper prototype objects, the data is within a certain value range or set... The list could go on and on. But also of course I c...
There are plenty of reasons why globals are evil in OOP. If the number or size of the objects needing sharing is too large to be efficiently passed around in function parameters, usually everyone recommends Dependency Injection instead of a global object. However, in the case where almost everyone needs to know about a...
What I have: I am developing an Active Directory layer which will be used by a huge application with several modules having several solutions and projects... I am fairly new to developing large scale solutions. Because the current requirements are mostly to deal with User and Group objects in AD, my current solution lo...
I'm kind of new to large scale software development in C++, and I was wondering on the design side of things. I was reading this question, and I thought that, overall, once we get past constant definitions and other trivial matters, C++ header files are just API definitions : They define what other programmers (or you...
So I have a REST backend (in node.js or Java doesn't matter but the example is in js). I try to have a service for each endpoint so that the /users endpoint has two files: usersRouter.js which includes the router endpoints with example code: router.get('/users/:username',function(req,res,next){ return userService....
Let's say I'm starting a Web Application project that uses a) ASP.NET MVC b) Entity Framework In terms of Software ARchitecture, correct me if I'm wrong, -1) Could I place all my Entity Framework code in a Data Access Layer folder ( DAL )? Furthermore, -2) Would it be correct to say that the Entity Framework code whi...
While I've never used a language that had built-in variable privacy, a book I'm reading by Douglas Crockford explains a way to create privacy in JavaScript, however it doesn't make sense to me so. The term "private" isn't something I think of as even being possible in a programming environment, since everyone working o...
Based on the tags listed from this "standard", is there an order of the tags that people typically follow? Even if it's not something that has been entirely accepted, but something proposed? I am trying to enforce a coding standard for a project, and it would be nice to have a guideline of what order I want our tags to...
Task as defined: User needs to be able to define their own variables and formulas to operate on those variables, to get output based on their inputs. Since formulas and variables and their inputs change often, user needs to have control. Example //inputs (may be entered directly or provided by database) $a = 4; $b = ...
Scenario Various types of files containing customer's data are being uploaded via FTP, and a POST is being made to a REST API to update a database table, which tells the system (a web app) which of those files are new. Users of the web app are notified of those new files, and can choose to import them into the app's db...
I've built a reasonably sized CLI app with everything split across different classes and namespaces in a logical way. However many components need to render output from within themselves. Which seems messy. To expand... The program copies content files and databases between servers. The main file kicks in, then loads o...
We have big legacy code working for big corporation connecting to multiple remote/local databases. The configuration files with IP, name and password for connecting to different databases are now handled manually. We have these files in git, but our passwords rotate on different schedule than our deployment, so we need...
Too often I run into students who: Use arrays instead of vectors, thinking that it's "faster" Use pointers because it's "faster" Reinvent-the-wheel, often copying-pasting terrible C-ish code from the Internet They have this ingrained impression that before they write "correct" code, they have to write "fast" code, at...
I'm using .NET with Windows Forms, but I believe there may be similar concerns with other toolkits. Suppose we have a list of objects of a certain type. Using an example to make the following easier to read, suppose there is a Category class to represent them. We display a list of them to allow a user to filter article...
Consider the following two cases: case 1: class A { private const string MyConst="Hello"; internal void CallMe() { System.Console.WriteLine(MyConst); } } Case2: class A { internal void CallMe() { System.Console.WriteLine("Hello"); } } Now if the CallMe() method wou...
I am working on a team that is adopting BDD for the first time. We are doing greenfield work building a market data system that allows users to request market data from different sources. We are using Mingle (https://www.thoughtworks.com/mingle/) and the BDD card hierarchy that has been set up is: A release consists of...
Python doesn't enforce any paradigm. It gives you freedom. Python provides encapsulation at module level. If I have a module A and have a module B with same interface. How do I sort of inherit B from A and override some functionality provided by B ?
Generally I have 3 classes, a container that holds an array of items and a special object that is another property of the container class. What I need to do is access the special object from an item object within the container. I see 2 ways of achieving this. class Container { protected $object; protected $ite...
So this question is specific to implementing auth in our system but I'm looking for high-level (just the architecture) solution or advice on which direction to head towards. Overview (TL;DR) Our company is building a new product (Product P) and we want to unify authentication for its API with a recently re-written prod...
I have these classes: public class Order { private Lazy<IEnumerable<Volume>> _volumes; long ID { get; private set; } string Description { get; private set; } IEnumerable<Volume> Volumes { get { return _volumes.Value; } } //etc.. } public class Volume { long ID { get; private set; } string ...
My boss is currently working on a database design for a multi-tenant capable ERP/CRM system, which will have a Sql Server backend. Some key points of the design: A server instance will host a "shared" database (unique model), plus one database per company (same model) The "shared" database have tables like contacts, u...
My question is simple, how should I comment during development so that it can be beneficial in the following cases: Understandable for my seniors while code reviewing. Should be able to search my work after sometime. Can be made in pseudo code form. Should be able to help juniors or other developers when they work on ...
Is it safe to make a non-synchronized method if it only calls synchronized methods? Say we have: public class SomeClass{ public synchronized void A(){ //Some code } public synchronized void B(){ //Some code } public synchronized void C(){ A(); B(); } } Should C()...
As many other projects we have to estimate our jira tasks up front. This is obviously not fun and I've started hacking on a simple webapp to "gameify" this tedious process. My idea is that an issue summary and description is presented to all participants and that when everyone has provided an upper plus a lower estima...
Lets say I have a string variable FirstName. FirstName can be null. I need to know if FirstName exists or not. Is it better to just use one variable: FirstName and if FirstName is empty assume that it doesn't exists OR Create two variables: Boolean HasFirstName and String FirstName The benefits of this is I know positi...
In our company we use the term admin and super admin. Admin - refers to the person who will handle the users, this is preferably from the external (maybe a manager of our client) Superadmin - refers to the person who will handle the admins, preferably this is internal (a personnel that should be working in our company)...
Is there a best practice for using Guava's ListenableFuture in parameters in API calls? Compare these two versions of an interface that internally does a compare-and-set (I'm using Guava's ListenableFuture): interface MyDao { ListenableFuture<Data> getData(String id); ListenableFuture<Boolean> updateData(Listen...
What kind of pattern or design can prevent the creation of a class packed with properties that aren't always used? Example class Car{ public string type; public string name; public DateTime manufactured; public int model; public Color color; public int VIN; // ..and on } public Car(string name, Co...
We currently have a platform with a SOA architecture in which the user's identity is propagated from the web application via middle tier services (REST and SOAP) until we actually query our data storage layer. We use the user's identity to apply access control at the entity layer. The user's identity is communicated be...
I wrote a simple REST API (just learning) using Go and I am calling it using python requests. I have two methods, "update_x", which updates the value of the resource, "get_x_times_n" which gets the value of the resource. Logically, I would think that I need (and can only use) put for "update_x" and get for "get_x_times...
I have a dillema working with CSS. I use a pre-processor to add all necessary vendor prefixes to CSS when it's served, keeping my source code short and simple. However the issue is, by far the most effective way to to edit styles realistically (and see real-time updating of the page) is to use the web page's dev tools ...
I have written a communication library for an industrial device protocol. The response frame contains a byte array as payload data. The payload data consists of several "objects“ of different types, like integers, floats and other, more complex data like dates or different string encodings. To make this more fun, the...
Well this could be a very wide question as every project have different philosophies. But meanwhile question is that We have lot of projects like Yii, Drupal, Apigility which requires full write permission on code folders itself ( I think for generating code from web browser page ) . This could be great feature but sti...
If we look at the vintage program Netscape Navigator or an early version of Microsoft Word, those programs were less than 50 MB in size. Now when I install google chrome it is 200 MB and desktop version of Slack is 300 MB. I read about some rule that programs will take all available memory no matter how much it is but ...
When your creating a project that has some sort of information that needs to be private (authentication details, etc), but you want to use some public repo like Github, are there anything that can be done to keep these things private? All I can really think of is ignore the file that has this data in it, but then if yo...
I'm implementing a custom HTTP 1.1 server. According to Page 35 of RFC 2616, an HTTP Request URI may take one of four forms. One of these forms is "absolute-URI", which is exactly what it sounds like. Let's say I have a server at http://www.example.com. My server is sent the following request: GET http://www.google.com...
When using variables of which their plural and singular are both the same, how do you name them? Are there any standards out there? For example: Series[] series // Plural Series series // Singular Indepth: To be specific, my collection of series needs to be called series (due to JSON formatting), would you conside...
I need to build a UI for entering values to the database. I am stuck with my class design to achieve it. I need a UI where I am able to enter the name of the system. Each system can have many options. Each option is associated with a TC(Technical chara). Each TC has another set of values which is described as TCset. Fo...
I am currently investigating the use of the ConnectSDK by LG. While reading through their documentation, I noticed there was no clear mention of wether there should be both a TV application and mobile application, or only a mobile application. The 'beaming' process, specifically, looks to work without having to create ...
Our intranet application is used to document and store office files. Both app and server are hosted remotely on the same server. Due to fact that our app server is changed every couple of years, we want to store files on a machine/location other then the app server. Since app and files were at the same location it was ...
I came across with following statements while reading the Clean Code book of Robert C. Martin. Chapter : 7 : Error Handling Page No : 109 ..In fact, wrapping third-party APIs is a best practice. When you wrap a third-party API, you minimize your dependencies upon it: You can choose to move to a different libra...
I have been using high-level OOP language (like C# and/or Java) for quite some time. I know patterns like the gang of four, can read and write code reasonably well and am considered a senior by his peers. I am moving to low-level C development. As a result of my background I am unfamiliar with many of the technologies ...
I recently got a chance to create a new Django app with the current stable version which exposes some Postgresql specific data types for models (docs) and got excited to have an Array. According the Real Python folks, this could be a way to introduce a tagging system (you can read the post here). This implementation wo...
I've been using the Slim Framework (v2) for a little while now to develop my user management system. They recently released Slim 3, and according to the upgrade guide, Slim v3 no longer has the concept of hooks. Hooks were removed as they duplicate the functionality already present in middlewares. You should be able ...
This is a question about ISO C, which contains this sentence: If an attempt is made to refer to an object defined with a volatile-qualified type through use of an lvalue with non-volatile-qualified type, the behavior is undefined. In ISO9899:1999 (C99) this appears in 6.7.3 Type Qualifiers. Firstly, if we entirely re...
I've written a couple of libraries since beginning to use C again last year. One thing that still needs addressing in both of these is the correct use of array-based lists - hereafter, ArrayLists. At present I tend to do one-off array allocations (usually static allocation) based on library constants (defines) that may...
A value type is one whose instances are themselves saved in variables. A reference type is a type whose instances are saved somewhere and variables only hold the addresses of the instances. Some languages, such as Java, have both types. For example String is a reference type and int is a value type. public static void ...
Background Here's the actual problem I'm working on: I want a way to represent cards in the card game Magic: The Gathering. Most cards in the game are normal-looking cards, but some of them are divided into two parts, each with its own name. Each half of these two-part cards is treated as a card itself. So for clari...
My question originates from the fact that the most common architectures are inherently imperative (i.e. the machine language is imperative). Would it be possible to create a computer architecture that is fundamentally functional, object oriented or declarative (or any other programming paradigm)? If so, would it be hel...
I am part of a small team which develops several internal apps for our company. We are in a process of becoming more Agile, this especially includes lots of automated testing. Now we are in a situation where, for the one or two apps which we have worked on most recently, we generally make small, reversible changes, run...
I am trying to come up with a theoretical solution to an NxN problem for data aggregation and storage. As an example I have a huge amount of data that comes in via a stream. The stream sends the data in points. Each point has 5 dimensions: Location Date Time Name Statistics This data then needs to be aggregated an...
Suppose I have a Repo A that imports a Repo B. I maintain both of them. Currently, I have some convenience functions that are useful for testing of both repos. They live in Repo B's test directory. When you install Repo B, it includes it test directory so that Repo A has access to these convenience functions. Is thi...
When did the trend of saying VanillaJS to refer to pure JavaScript come into widespread. Is the website Vanilla-js the discoverer of the term VanillaJS or was this term used even before the launch of this website?
My objects serialize() method is dependent on a call to its clone() method, because of its options to get rid of unwanted data without changing the original instance: serialize: function(opt_filters) { // Cloning even if not filtering. var clone = this.clone().applyFilters(opt_filters); return clone.doWhats...
I'm trying to compare the performance of an application that has recently been converted from .NET2 to .NET4. From my perfomance tests it seems that although page response times are generally a bit better under .NET4, they are worse than the equivalent under .NET2 when under stress. From what i've seen so far is that...
We have a problem we are trying to solve where we have a number of different containers. Each container can hold a number of different items (call them "item A" through to "item H"). Each container can handle a different ratio of the items before it is full. So taking just three of the containers the ratios the can han...
As someone who's worked effectively with Agile before, I am trying to convince my current employers of its benefits. However, management are insistent that we retain the ability to make upfront estimates in order to assess the business value of projects. Most of my customers are internal, and I was recently tasked with...
Given that SAP modules are architected and managed by SAP itself. However, small changes are possible at the customer's end. How can an ABAPer on the client's side take the role of an architect at SAP that designs SAP modules? So what does an architect at the client's side have left to do?
The problem I am working on an application with ~ 1000 tables in a sql server database. I am having a recurring issue with a sql script. The script is used by the consulting team to "clean" some part of the database and sometimes it will fail because a new table with a foreign key constraint was added a few month ago a...
I want to create a new session, the new session will be created by logging in (naturally). Should I pass the username and password: via URL (POST request to session?username=:username&password=:password) or should I use a header instead (for instance - Authorization?)? I want to stress that the session is not existen...
I'm studying Dependency Injection in JavaScript. I've learned what I need to accomplish, according to Wikipedia, The client delegates to external code (the injector) the responsibility of providing its dependencies. The client is not allowed to call the injector code.[2] It is the injecting code that constructs the se...
I have a site that lists several items per page. When the user clicks he can see each item's prices (a list of about 10-20). They are not visible at first because the page will be very long. I want to tag them with the offers schema.org microdata structure. How can I make this tagging seo friendly? Is it only possibl...
I need an algorithm to detect incorrect answers in memorization of sentences. Confused? Let me show you. I need to repeat the following sentence by memorization: The quick brown fox jumps over the lazy dog. My memorized version (this is an example, people) is this: Quick the brown fox jumped over my lazy fat dog. If YO...
I have a background in .NET, specifically in C# WPF and ASP.Net, but now I am going to use more golang and C. Consider the following situation as an example: The software I should program should should basically upload data and present that upload-process using a GUI. Each language used in production has usually (exter...
So, I have a packaging center A. And I have n points scattered around A. Let's call them i1, i2 ... in. I have a maximum distance threshold, called D. My task is to break those n points into groups of at maximum m each points. Each group cannot exceed m points, in such a manner that a person starting from A and going t...
I am looking for algorithm or idea for the following problem. Suppose we have a data type, say 64-bit integer. Now we have a relatively small set of such items, say few hundred at most. The simplest way to program that is to have a list of items, that means a sparse set. Now the problem: I want to compress that list so...
This is one of my functions I have in a module: Function Get-DatabaseUser { [CmdletBinding()] Param() Write-Verbose 'Getting database...' $Database = Get-Database Write-Debug('Value of $Database: {0}' -f $Database) if($Database -eq $null) { $ErrorRecord = New-ErrorRecord "Database c...
I am creating an AST, and I am currently introducing the concept of "scope". By implementing a scope, wherever an identifier (variable name) is used, I am able to determine its original declaration. For the scope object, I was going to implement a dictionary as the underlying data structure. The dictionary would be key...
Interesting question came up while designing interfaces at work, now resolved, but I want to ask about the theory behind it. Is it incorrect to say that properly typed data members of a class provide encapsulation? (e.g. a Boost Units type that has conversions well defined between other like units, not a typedef'd/boxe...
"Traditional" namespaces in the sense that Java, C#, and PHP use it. Spaces to organize related classes and sub-namespaces that span across multiple files. How do I rewire my brain to think without namespaces for organizing related classes together?
Since search engines don't go through every webpage on the internet when searching for something, how are they able to find an exact string of words? For example, using quotes in Google, like "apples bananas pears" will only show results that contain those three words in that exact order.
In particular, if a class defines its own copy constructor, copy-assignment operator, or destructor, the move constructor and move-assignment operator are not synthesized. —— quote from "13.6.2. Move Constructor and Move Assignment" Why some compilers do not synthesize the move operations at all per this paragraph in...
I'm trying, as a test, to create Dependency Injection from scratch in JavaScript. Consider the following code structure, which outputs an Alert: Does it satisfy the terms of the Dependency Inversion Principle? Is it technically Dependency Injection? and if not, what structural changes are necessary? - function App(na...
I`ve built a simple but yet effective delphi-7 application that solves sudoku puzzles, and a keygen that produces a unique serial key for each PC. My purpose is not to make money, I want to understand the methods of commercial uses of an application at its simplest form. I have zero knowledge and experience about lice...
I have been stuck at a requirement for way too long too handle it :(. Our company is having increased number of customers who wants to upgrade or downgrade their subscription. For now, the subscription-customer relation is at follows: Every Customer has its own Combo, like the following: Every Combo is bind to sev...
Say I have two members which share a server. Both members have a game that is accessible to anyone and after playing, it records high scores by sending a request to write to a file on the server. However game A should only be allowed and to write to its own file as well as game B. Is there any way to authenticate which...
I'm working on a toy language. Until now, multiple files have been compiled by merging the ASTs of each file and then running the semantic analysis and code generation phase on the merged AST. Now I'd like to implement incremental builds. My language does not have header files. Therefore, I need to persist the symbol t...
package foo; public class scj{ protected void disp() { System.out.println("package"); } } ********************* import foo.scj; public class aq extends scj{ public static void main(String args[]) {disp(); } } If disp is static , then program runs perfectly fine. But for non static it gives error that-non static ...
I rewrote my makefile a while back to get the benefit of greedily searching for and compiling all sources under some root folder. I'm very happy with it except for the fact that the source libraries I include as submodules tend to have a lot of junk files, e.g. examples, tests, or other sources I don't need... and the ...
I am coming around with TDD/BDD. I am a bit confused though, when it comes to initially writing my BDD tests and then adding more tests after the very broad tests. For Example, lets say that I am giving requirements first: It should take in an array. It should print a list. It should look for this specific condition. ...
When I want to create an object which aggregates other objects, I find myself wanting to give access to the internal objects instead of revealing the interface to the internal objects with passthrough functions. For example, say we have two objects: class Engine; using EnginePtr = unique_ptr<Engine>; class Engine { pub...
I've read many questions and articles on exception handling in Python (and in general), but I still think that it's the most confusing thing ever. I ended up doing something like this: # error class for exceptions specific to this script class MyError(Exception): pass # error class for exceptions in MyClass, # which c...
I recently moved into web development using ASP.NET MVC. The language I use is C#. Having considerable experience in C makes me look for optimized coding standards (memory, efficient data structures and speed of the loops to name a few). But my peers who have years of experience in this domain do not seem to take into ...
Distributed Hash Tables are a great way to store immutable data in a resilient way. However, I am wondering about how it would be possible to store new versions of old data in this system. Because it is impossible in a distributed network to unconditionally trust the other party, a way is needed to ensure that another ...
Wikipedia explains: A dependency is an object that can be used (a service). An injection is the passing of a dependency to a dependent object (a client) that would use it. But studying AngularJS's DI implementation, I noticed it includes many different structures to be injected such as: service value factory pro...
I am extending SimpleExpandableListAdapter in Android. I don't think Android's adapter is implemented very well, in that its constructors have a large number of rather complicated arguments and it has no setters or builder. In my class, most of those arguments are not dependent on the calling class so I want to build t...
Question: Does the term "readability" refer also to the transparency of code functionality? For Example: I read that a downside of Dependency Injection is a sacrifice to readability. The idea being that to follow all of the strict syntax of a DI library, one has to write much more code than would be required to write t...
I am currently working on a small game I did in about ten days. Since I am programming for myself, I am being lazy and going to the easiest solution with (too) little concern about bad code quality. However I am reaching a point where it begins to matter. I am starting to move booleans that references states into class...