instruction stringlengths 34 19.9k |
|---|
I do not know much about OO-languages, but from what I have seen, it seems most class-based OO-languages uses a keyword new (or something equivalent) to create an object. Prototype-based OO-languages like JavaScript even fake it.
From a viewpoint of keeping the syntax simple, why not leave out the new keyword and use o... |
I have read the following question regarding whether it is best to use objects with fully or partially populated data members. The 3 suggestions were:
that perhaps using a fully populated ORM model may not have as much overhead as you might expect (testing requried);
an incorrect model was being used if only a limited... |
I want to study Ruby and RoR for some things I'll have to make, but almost every book, videos or any kind of source I find is outated, where the most current book I could find (link here) is one of the version 2.1 (latest stable version of Ruby is 2.2.0), and in the case of Rails I only find books about RoR 3.x or at m... |
I have recently "inherited" a project written in ASP.Net MVC which has quite a few issues
and I'm looking for suggestions on how to go about refactoring the code.
The technical issues found so far are:
All the business logic is written into stored procedures (1000+ SP's).
No unit tests.
View Models are poorly used.
... |
I have a money management tool which has users. Each user may have several accounts/funds (e.g. bank account). For each account/fund there may be thousands of transactions.
Users may only view their accounts and transactions so no need for cross reference between different users like other apps (e.g. message board, whe... |
Here's a scenario where I'm wondering whether to denormalize a relational database (MS SQL).
Text description of the requirement
I have users (stored in a users table).
Users belong to Accounts:
An account is created before its users are created
Every user must belong to exactly one account (neither no account, nor mo... |
I recently learned of the trick for finding out if a binary number is odd or even.
If the last bit in the number is 0, then the number is even. If it ends in a 1, then the number is odd.
In the tutorial in which I read this, is stated that this could be applied to programming if you "AND" the number with the binary n... |
I'm fairly new at using design patterns and I am currently making a small game for my uni course that I have to use the decorator pattern for creating the different classes of NPC however I think that I have misunderstood how the decorator pattern works.
At the moment all what changes between the classes of NPC's are ... |
I'm going to use Java for code/idea demonstration.
Imagine it's needed to define two interfaces: Observer and Observable (observer pattern). It's a good idea to have two generic interfaces, so there is no restriction on what is being observed, who is observing it (is even using generics about this?).
Java has a concret... |
I'm writing an app that has a client for iOS, Android, and the web. The server is hosted on Google App Engine (Java). REST is used for the communication between clients and server.
In order to ensure a uniform user experience across platforms, as a software designer, I want to write Behavior Driven Development (BDD) st... |
The title says it all, the more I do research about piracy and the tools used to crack an app the more I think it is just wasted time.
My biggest threat is that my app is being cracked and uploaded again within minutes after I released it. But I'm not sure how harmful it will be to my revenue, if there even will be rev... |
Are the new, functionally-inspired features of Java 8 well-regarded within the enterprise development community? Have they been adopted by large companies? Have coding standards been updated to account for them?
I'm in the process of completing a programming exercise for an interview. I don't write much Java, and this ... |
I'm creating a website with Laravel for the first time. I checked relationships documentation today and it seems that Laravel just uses simple SQL queries.
class User extends Eloquent {
public function phone()
{
return $this->hasOne('Phone');
}
}
$phone = User::find(1)->phone;
And it's basically... |
Imagine I have the following DAO method:
public Employee getEmployeeById(Integer id){
NamedParameterJdbcTemplate jdbcTemplate = new NamedParameterJdbcTemplate(getJdbcTemplate());
String sql = "SELECT * FROM users WHERE id = :userId";
Map<String, Object> parameterMap = new HashMap<String, Object>();
para... |
I read about objects models on Wikipedia, but it is too abstract to really make much sense to me. Can someone explain what an object model is in plain English?
|
I've just started learning about fulltext indexing and searching in MySQL and I've stumbled upon this list containing all of the "stop words" used in MySQL. I cannot understand what is tue purpose of these stop words, since this list contains a lot of actual words that I may want to search for, such as if I had a post ... |
Generally I need size-efficient data structure similar to std::priority_queue but stable (preserving order of insertion).
By adding just 4 bytes to the object I could have 1 byte serving as priority and 3 bytes as counter to keep the order of insertion. Closest competitor - std::forward_list - would add an overhead of ... |
I am wondering if there is an easy way to save and load a decorated object in c++ as i have never done file handling in C++ before.
Currently the only object type I need to save is objects that stores values for health, damage etc. and each of these objects has at least 1 decorator. I know i could make an save functio... |
So I'm writing an ORM for NodeJS and using Mocha + Chai to test it.
What I want to know is, what tests I should write to it, insertion tests should also have a querying test so I can check if the tool has inserted the correct data?
Also, how should I organize the tests? Any example of how to begin to write those tests?... |
Given a string of decimal digits, I have to find the number of all substrings divisible by 3 in the range L to R [both inclusive], where L & R are index[1-based] of the specified string
string length <= 100000
I've tried the Naive approach of iterating over all possible substrings & obtaining the answer, but that is no... |
I'm here to clarify my understanding of the run times of these 2 algorithms:
Algorithm1(n):
For i = 1 to n
j = 1
while i+j < n
j = j+1
and
Algorithm2(n):
For i = 1 to n
j = 1
while i*j < n
j = j+1
The first algorithm I believe is O(n) because the inner loop is bounded by n, and the whi... |
I have a quad-tree structure where each node has some of its own data, but there is also data which applies to the tree as a whole.
I'll explain my current solution and I would appreciate feedback on whether this is the best solution or whether better solutions exist.
I have two classes:
One for the node
One for the t... |
Let's explain my question with example I have some integer sets for example
S1 = {2,3}
S2 = {2, 5}
S3 = {4, 5}
S4 = {4}
S5 = {5}
And I have sample set Ssample with 4 elements {2, 3, 4, 5}.
So now I want to find minimum number of sets to build Ssample. In this case I can use S1 and S3 because S1 contains {2, 3} and... |
I'm trying to figure out the best way to recommend images based on past classifications using k-means clusters. What I have done is mapped the RGB values of a set of images, performed a k-means cluster analysis on those RGB values, and attached a "rating" to each image. This has created Voronoi cells similar to this gr... |
Say I have a list {1,3,7,2,11,8,2} and I want to take x elements from the list and get the value 15.5.
Is there an algorithm that would give me x elements in a list that, when added together, get nearest to this given value?
There is no preferred amount of elements, I just want to get as close to the given as possible... |
I'm probably going to be giving a presentation to my company (mainly management, but also senior developers) on the benefits of moving to Git from a centralized TFS setup. I know that I massively prefer Git because of its speed and IMHO the improved workflow of the easy branching model, but what are the best (most con... |
I'm looking into the possibilities of integrating Version Control so that me and my team can work on code at the same time without having to worry about overwriting each others work. Previously this was easy to maintain as there were only three of us. However as our team has now grown it's become a key consideration mo... |
Here's the scenario.
There's a large, organically grown application written in some language and manner that makes it difficult to test. It works but is hard to maintain.
Specifications are woolly, so even if the code was amenable, it's hard to know what things should be doing without doing them.
You want to get it ... |
I'm using an Optional class quite similar to that of boost. For semantic reasons, I switched an attribute of the same (structured) type in some class definitions (and therefore also in method signatures) from mandatory to optional. So, in each related class header file, I included the header with the definition of Opti... |
As it is often classified at school/college level, popular programming languages (C#, Java, C++) are all 3rd generation languages (with higher level of abstraction from the machine's physical parts). Also, assembly languages are classified as 2nd and machine languages as 1st generation languages.
Initially I was thinki... |
Let's say we have an interface Foo with a method "public void someMethod()", and we have one or multiple abstract classes that "implement" Foo but don't necessarily themselves provide an implementation for someMethod().
Would it be good design to put for example "public abstract void someMethod()" in these abstract cla... |
I really tried searching about this in the internet but came upon diverse search results which barely specified what must be done specifficaly.
I'm now running ubuntu and php5 through nginx, amongst other things.
How is it that I can specify different layout and functionalities for mobile devices under the url "https:/... |
I´m creating a new website. For that I´m using a free bootstrap template. On top of my index page I have:
A Design by W3layouts
Author: W3layout
Author URL: http://w3layouts.com
License: Creative Commons Attribution 3.0 Unported
License URL: http://creativecommons.org/licenses/by/3.0/
Can I delete or ... |
I came across this in the http_parser library of node.js implementation. When I bitwise-OR an ASCII capitalized character code, it converts into its lowercase version. The lowercase version remains as it is.
Why is a bitwise OR causing the ASCII code to change to the lowercase letter?
|
I am looking to add an audit trail to our Rails app. At the moment, I am trying to lock down my requirements and determine the appropriate software architecture.
Our website gets about one hundred million page requests a week, and growing. We currently log a subset of actions into a MySQL table, but that table is much ... |
I have spent the past two days investigating which technology I will use to support translations of text strings (as part of an overall internationalization migration) for an archaic (VC6) Windows desktop application (with MFC) that is being migrated to Visual Studio 2013 at the same time that it is being international... |
Nowdays it's goes to be very fancy to have grunt/gulp build phases who concatenate and minify and organize javascript code.
And I agree that this is important for production.
But as a developer, I see inconvenience there:
additional step to run code (execute gulp/grunt command)
hard to navigate in one concatenated fi... |
I am trying my hands on JPA. For this I am thinking of using the example of a student admission process as shown in the diagram below.
Is this design good ?
Any suggestions for improvement are more than welcome.
I am also confused about what Entity classes should I create for this.
Especially for College_Major, should... |
I'm looking to build an email notification system using codeigniter. Now the system in question is one of a 2nd hand online store. For example say person A would like a chair. When they search the system and nothing appears I would like them to subscribe to any notification regarding the chair. So when person B uploads... |
What's the difference between using (values …) versus (list …) (or literally '(one two three …)) to return multiple values from a lambda (or other implicit progn)? Does it create some special glue to multiple-value-bind? Superficially, I can't see any difference and am curious whether it's merely a convention for multi... |
In our Java codebase I keep seeing the following pattern:
/**
This is a stateless utility class
that groups useful foo-related operations, often with side effects.
*/
public class FooUtil {
public int foo(...) {...}
public void bar(...) {...}
}
/**
This class does applied foo-related things.
*/
class FooSomethi... |
I'm in the middle of uploading a project to github. My software uses some icons which are licensed: "Creative Commons (CC BY 3.0 US)"
Should I hardcode the credits in a... let's say "Help->About" dialog for the software or can I ship a CREDITS.txt file inside the source code tree on github. For example inside icons fol... |
Why isn't (almost) pure C used instead of the C preprocessor?
Sure I understand it would be a little more verbose. For example:
#define PI 3.14159
If we had regular C as preprocessor language, the above could be rewritten to something like:
#define PI {printf("3.14159");}
The idea is to not substitute {printf(...)} f... |
I have many methods in many repositories that have the same logical flow:
Retrieve value from Cache
Check value
If no value, fetch from Database
Update Cache
Return value
Is there a way to refactor these methods in such a way that I don't have to rewrite the same lines over and over again?
I'm using an MVC pattern ... |
In JavaScript, the Good Parts, Douglas Crockford wrote:
JavaScript has two sets of equality operators: === and !==, and their evil twins == and !=. The good ones work the way you would expect. If the two operands are of the same type and have the same value, then === produces true and !== produces false. The evil t... |
This is an unusual question since I don't believe it lends itself to typical software development practices but I hope you can prove me wrong.
In MATLAB, my team have created several signal processing components, where data goes in one end, and different data comes out the other. What each of the components do is unimp... |
Angle A is a degree angle that keeps increasing by increments and Angle B is the stopping point of Angle A (think 'Spin-the-bottle' where Angle A is the current angle of the bottle Angle B is the angle needed to point to your crush and the bottle spins at a fixed rate clock-wise).
To do this, I've been trying to compa... |
I am building a multi language website on ExtJS, where I have covered all the technical aspects of the multi language aspect.
How would deal with different string lengths? Lets say I design a 160px space for an specific label. That label is 120px long on Spanish, so everything ok with that; but that same label is 200px... |
When I see for and while loops all over production codes and mammoth projects, the last time I saw a do while loop is for a university assignment involving menu-based console input program. About 50 lines long, at most.
Have you seen real-world applications of the do while loop construct? In what way is such a construc... |
This is my homework(I have attempted it, and there are no references for questions like these)
Determine whether or not these functions are polynomial run time and determine the constant c for O(n^c) based on these functions:
3^(log base2 (n))
(log base2 (n))!
My intuition tells me yes for both.
Case 1: The exponent... |
I have an app build with JSF2.x Spring IoC,transactions and JPA over Hibernate. This is a fully functional call center app.
The challenge is that now I want to add some HR functionality where the HR team would perform various tasks. My initial thought was to create this as an module in order to be able to deploy/undepl... |
I'm sorry if this has been asked but I'm not quite sure how to search for it. I'm having a bit of trouble understanding how mail() works in PHP. The way I see it, using that function, I can send e-mails from any user on my mail server - existent or not, without needing any credentials or anything. I doubt the guys fro... |
Is it possible in theory to recover after a process is mistakenly pointed-out to read from a wrong memory address, rather than terminating it?
Let say an error while working with registers lead the processor to read a random place on memory and therefore throwing an illegal instruction exception. At this point, are the... |
This might be a big or broad question, but I simply cannot find a proper answer to this myself. Right now I'm struggling to find a starting point for the application I'm trying to make.
My idea is to have a chat moderation application with a webinterface that is completely modular, in the backend and frontend. The prob... |
Today, I discovered a few exception specifications in legacy code I've to maintain, when Cppcheck 1.68 ([Inconclusive] but correctly) pointed out that the specified exceptions are not handled in specific portions of the code.
[Inconclusive] Unhandled exception specification when calling function [...]. Either use a tr... |
Because there is no language feature in C to protect assignment to global variables would you recommend doing something like this?
Take this example:
We have a module with the header file called module.h and
implementation file module.c. The module contains a global variable
called global_variable. global_variable... |
I often write code which translates entities in the database to domain objects. These entities often have fields which are constrained and translate to enumerations in the domain objects. In some cases, though, the fields can be null.
For example, imagine I have a PrintJob entity with a Status field that can be New... |
Commonly domain objects have properties which can be represented by a built-in type but whose valid values are a subset of the values which may be represented by that type.
In these cases, the value can be stored using the built-in type but it is necessary to ensure values are always validated at the point of entry, ot... |
I am currently maintaining a code that makes liberal use of raw pointers where std::vector would be a better option. Worse, these pointers are not always properly handled (when run using Intel Inspector, I get the warning message "Warning: Only the first 100,000 memory issues are reported"). As such, I have been slowly... |
Recently I was looking for a program that will run as a daemon and find files that have the same size/type, check if they're the same, then make both a hard link to a single copy if they are. And I started wondering why Operating Systems don't do this automatically.
I thought maybe because it would be time consuming, b... |
I am cleaning up my code by way of removing duplicates, and found two classes that were almost identical, out of 55 lines, only a single predicate in an if statement differed between them.
Both classes also had a suite of tests, which were almost identical copies as well.
The two original classes were FooApiAuthenticat... |
I am working on a service that lets event organizers sell tickets to their events online (a lot like Eventbrite to be honest).
The customers then print the tickets themselves (each ticket has a barcode) and present them at the event, where they are scanned using a mobile app. The mobile app communicates with the serve... |
I was wondering... what is considered the best practice to instantiate blank value objects? (in Java)
E.g. Assume we have some value object class Foo, that could be blank.
Would creating methods like these be a clean solution? (And perhaps adding in a "Blankable" interface or something).
interface Blankable {
publi... |
In MVC the Controller is the go-between for the View and the Model. So the Controller should be the one that observes or receives changes from the Model and View and updates the other accordingly. I know for sure that doesn't break MVC.
But what if the Controller registers and unregisters the View as observer to the M... |
These questions are very similar: TDD for batch processing: How to do it? and TDD: how to test file outputs? but I'm still left wondering some things
The app processes files/pdfs. It takes them from one FTP server, processes/reads file content, places them in a destination FTP server, depending on content read.
How can... |
I'm in the process of designing a browser based system that will allow non-technical users to quickly and easily change the content of certain parts of a web page via a WYSIWYG template-based drag-and-drop editor. Essentially, the user can choose from a few prepared templates, drop some image files into predefined area... |
If you had a pretty novel idea that involved a new algorithm. Like lets say you were the first person to think of orbitz.com or kayak.com (travel sites) and you were able to and wanted to implement all of the novel algorithm clientside in javascript.
Is it possible to obfuscate it 100% where you cant reverse engineer ... |
In current C++ when body of if statements contain only one command then:
Parenthesis around if condition are mandatory but block are optional. So, both examples are OK:
if ( condition ) { return 0; }
if ( condition ) return 0;
But is it theoretically possible to do it also oppositely?:
Blocks mandatory and parenthesi... |
I want to write a library with "no resource leak guarantee" feature. So I shall know whether each method allocates any resource or not.
It may change the code. For example:
void foo()
{
methodDontAllocateAnyResources();
methodCanThrow();
}
void bar()
methodAllocateSomeResources();
try{
methodCanThrow();
... |
I'm writing a Python tool to parse a log file from game server. The log file is of format:
ms:classname::id::method::arg1::arg2....
There are a lot of classes, and a lot of methods for each class, and each of them has its own format (number and meaning of arguments). I want to reconstruct the game (or at least releva... |
We have a pretty good code review process, but there are couple of issues. The most annoying problem is merging. From time to time the number of stuff to merge grows rapidly and some of the commits are getting old. As a result, rebasing is a pain (conflicts).
What can we do to avoid it? I can think of two possible solu... |
I develop a browser based game with node.js in back and HTML5 canvas in front-end.
It use WebSockets for communication.
My plan is to generate business events in client side, e.g.: "finishJob".
Client will store all relevant information up to date.
client doesn't have to call server every time it need some data e.g: p... |
I am new to unit testing and using Microsoft's unit testing library for following piece of code. When I execute the code normally it executes fine, however when I run unit test written for this code I get a nullreference error at the point of datacontext initialization.
Following is a method similar to the one i am try... |
What is the best practice to work with several Java modules from different GitHub sources using IntelliJ?
This might be an odd qeustion but I do not know what the standard workflow is to achieve what I have in mind.
The current situation
I develop a Java project with IntelliJ and I manage my code with GitHub. The proj... |
I stumbled about a Cppcheck warning (an inconclusive one), that I mistakenly used & instead of &&:
/// @param code identifies the command. Only the lower 16 bits of are being processed
int encodeCmdState(bool finished, int code, bool errorneous)
{
return
(finished & 1) |
((code & 0xffff)<<1) |
... |
When developing for the web you will inevitably end up referencing a lot of files that eventually all get included and combined into a finished product. I specifically develop a lot of Wordpress sites and, as an example, the project I'm working on right now includes a file called footer.php which simply contains this c... |
Is it possible to write code (or complete software, rather than a piece of code) that won't work properly when run on a CPU that has less than N number of cores? Without checking it explicitly and failing on purpose:
IF (noOfCores < 4) THEN don't run properly on purpose
I'm looking at a game's (Dragon Age: Inquisition)... |
I know in C#, by default, referenced type variables are passed by reference to a method. I have a function which sometimes I just need its return value and sometimes both return value and the changes on the input object are needed outside of the function.
Then I wrote it as the following:
public static List<RuleSet> L... |
I would like to differentiate between exceptions coming from business logic like
requested database record does not exist
attempt to store invalid business data (validation failed)
provided CSV file has wrong format
from standard system exceptions like
database connection timeout
file I/O error
out of memory
I gene... |
Situation
Mobile application store owners are known to explicitly forbid some application extensibility scenarios.
Apple:
2.7 Apps that download code in any way or form will be rejected
2.8 Apps that install or launch other executable code will be rejected
https://developer.apple.com/app-store/review/guidelines/#funct... |
I don't know if this is the correct place to ask this question but I'll ask it here anyway.
I don't know much about programming (I only ever learned MATLAB!) but I wonder if there is a simple way to write a code to check a website every x minutes, say, to see if a certain thing changes and notify me when it does?
I hop... |
We are developing website that we charge money from members to join it as membership annual cost, so, we decided to put a plan for the second stage so we are choosing now the load balancer that we will use for our web application. I suggested HAProxy but one of my friends told me that HAProxy is under GPL and LGPL so i... |
My goal is to understand how to handle jobs coming from the client side at very high frequency each job is either CPU-intensive or I/O intensive, but both types of jobs are continuously arriving at my server.
For example if ThreadPoolExecutor is configured with 50 threads and request frequency is 100 req/sec and each C... |
When a dataset is saved in the software I use, a http request is triggered (fire-and-forget).
Information like the timestamp, the user and the changes made are listed in the GET parameters.
Now I need to write an application which is able to take thousands of requests per minute and write them into a MySQL database.
I ... |
At my workplace we are currently looking to redesign our application stack on the web. We are satisfied and accepted that our server will be Node.js but we are finding it very difficult to find a front-end framework we can agree on.
I'm not asking for opinions on particular frameworks (there are tons of other resources... |
modern dynamic programming languages like Python, Ruby and Javascript all take the approach of treating everything as an object, what's the benefit of this approach, and what's the curse of it?
Benefit I can think of: first class functions, duck typing.
Drawbacks:performance issue, especially performance of primitive ... |
I'm writing a simple language compiler,currently it's support functional programming only.
I want to support OOP concept, but I don't know how exactly I can represent an object ? just where to start .
Edit:
I just want to how to represent a class data type,not how to inheritance,.. etc.
|
I have a small project which I want to publish on github. The problem is that my project contains a database. I don't know what is the best way to attach the database structure.
I may get the create queries and put in a file called db.sql, but is this the best way?
|
So I have got an application that during various steps during a user's process will transmit and receive data from external API's.
Currently the way this is handled is fairly rudimentary. There will be a POST, DELETE, or PUT to the app. The application will then make the necessary updates in the DB and submit any in... |
Context
I'm designing a database which, simplified, should be able to handle users sending job requests to each other, and after that a job can be started, finished, and reviewed. The design should be scalable (think millions of users).
Approaches I've considered:
Gargantuan table
One approach, probably not the best on... |
I am learning about analysis of algorithms.
I came across the term "upper bound" and "lower bound" in "worst-case" running time of an algorithm.
Are they applicable to only the "worst case" or can be used with other cases also ("average case " and "best case")?
|
I am currently wrestling around with some GUI code where I have a table whose rows correspond to some object, let's say a Person object. When the table initializes, it fills the table with the Person objects that it knows about - say Bob, Andy, and Tom. The rest of the rows item's (row.getItem()) are null. In this part... |
In functional programming languages, a developer is always cautious about writing pure functions. Some functional languages simply do not allow impure functions, and some other functional languages force to to state explicitly when something impure is happening. But in imperative languages, there is usually no such dis... |
I am trying to build an Asp.Net Web Form project to use at my job. We work with a lot of excel files and a large task for me and others at my company is combining/comparing/updating data in these excel files. My goal is to build a webpage and use asp.net Fileupload to parse our excel files and in the code-behind format... |
I have a non-binary tree.
I want to randomly find a "sub-trees" that are connected from root to leaf which must have at least n leaf-nodes (leaf-nodes of sub-tree must be leaf-nodes of given tree).
For example: given a tree as below
*A
/ \
B C
/ \ \
*E D *F
... |
goto statements can sometimes be useful to go down (to lower lines of code) in code, but can create a mess if used to go up (to higher lines of code). Therefore, I am wondering if there is any language that only allows goto statement to go down, e.g, godown.
Edit:
My main motivation for asking this question is this que... |
I know that some financial organizations still use "dead" languages such as COBOL. I'm wondering what will happen in the future, when almost no one will program in those languages, and the maintenance of their systems will be a nightmare because there won't be any resources. (This is what I think will happen).
Are the... |
I've been an iOS developer for about 5 years. There are still things that NSString and NSArray do that I didn't know they could. All optional attributes and behaviors that I haven't seen, because I've never actually sat down and memorized all of the optionals and capabilities of the NSString class. I know the most of t... |
I ask this question based on the fact that currently my environment is under constant change due to the type of work we do. We do not always work on a project bases we often have smaller changes that just go through a quick change request process to trigger a developer to make the necessary changes. But my question rel... |
I am trying to build an application which tries to find out if a system is suffering from backlog (# of requests which are open are more than what the team can handle)
I have the below parameters alone and with these how can I find the 'ideal' number of open requests so that the system does not have any backlog.
Priori... |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.