instruction stringlengths 34 19.9k |
|---|
I had to implement some code which traversed a small object hierarchy to fetch a value and display it in a TextView object (this is Android / Java). I had to do this 6 times to populate 6 TextViews for various values in the object hierarchy.
My implementation was Implementation B. But upon review, my colleague disagree... |
I'm currently writing a python script. It's currently about 400 lines long, and it seems like it's getting a bit long, as when I'm trying to scroll through it with eclipse it takes a bit to get from function A to function B. The structure is that it reads in a file, and then performs actions on what it reads in dependi... |
I recently came across a piece of code something like this (roughly C#):
public bool ValidateStuff(ref ArrayList listOfErrors, Stuff thingsToValidate)
{
if (!thingsToValidate.isValid() )
{
errors.add("New error!");
}
}
ArrayList errors = [];
bool valid = ValidateStuff(ref errors, stuffToValidate);
... |
Here is a very simplified example. This isn't necessarily a language-specific question, and I ask that you ignore the many other ways the function can be written, and changes that can be made to it.. Color is of a unique type
string CanLeaveWithoutUmbrella()
{
if(sky.Color.Equals(Color.Blue))
{
return "... |
I am learning ZeroMQ and came across the Majordomo Protocol. I am wondering if I'm understanding this correctly, is the use case the same as.. for example.. the Microsoft Azure AppFabric service? Would I use Majordomo if I wanted to create an AppFabric-like servie bus? Or would I do Pub/Sub+Request/Reply?
If you are no... |
I have a Unix script which is called by a scheduler (CTRL M) every 3 seconds. The script queries an external database(not belonging to my application and therefore I can only query it) to check for new records. Currently it stores the last run timestamp in a local table and on the next poll queries the external databas... |
I'm new to web development. From looking at popular open-source frameworks for both front-end and back-end, I have a general idea of what the modern full-stack web setup looks like:
Database <-> Back-end language ~ REST API <-> Front-end
Notes:
The back-end language (Python, Ruby, PHP, Java) generates the API, which i... |
I have been tasked with setting up a SQL Development environment, and i was wondering if anyone has any advice on getting this right?
So far, I have restored the prod DB onto another box, and changed all our SSIS packages to use XML configuration files so we can deploy them to either environment without changing the D... |
Does this function means its calculating x=(x-1) + x^2?
Function unknown(x)
if ( x == 1 )
return 1
else
return unknown(x‐1) + x*x
|
I want to create simple language learning applications to help friends in learning languages. A simple Java console application would do the trick, but the Windows console does not seem to handle Unicode (and I need my software to work with all kinds of special letters at once).
Googling it, I get the idea there might ... |
I'm trying to figure out if I can distribute the Faenza icons, which are GPL licensed, with some MIT-licensed software I'm working on. What does the GPL license really mean when applied to a non-software medium, like an icon set, that is primarily used in software applications?
If I load the icons dynamically from ex... |
We are a team of 3 developers (2 experienced devs and a junior).
We just started a brand new project. We've designed the application, concentrated efforts on choosing the right architecture and now we are laying the first lines of code. We are writing the core of it, what will be the foundation of the entire applicatio... |
Consider a micro service infrastructure in which each service is responsible for one set of activities, and exposes a RESTful interface to its functionality. For example, assume a chat application.
We might have one service which is responsible for creating users, and a second service that is responsible for creating m... |
I am in a bit of an awkward programming situation, and it will help me a lot to get your input in this situation.
I am building a web app which expects to authenticate users from another, separate application (through API calls), and also authenticate users from it's own database. Essentially, there are two separate us... |
When starting to learn programming you would usually point someone over to Code Academy, or Learn Python the Hard Way or even The C Programming language and tell them start writing code until it works.
But how would one proceed if he wants to learn QA?
More specifically, a programmer who wants to learn about the QA pro... |
Recently we developed a web app that uses the following tech stack:
hibernate as orm
spring
extjs (MVC javascript front end)
For 1 business object, let it be a Personnel, we have:
1) a Personnel class (hibernate)
2) PersonnelDTO (will explain why we needed this)
3) a Personnel javascript model for Extjs (I don't know... |
I just listened to Software engineering Radio podcast on components. Their description of components were very vague, they made them sound like lower level versions of functions. I am trying to figure out what components mean in the context of the composite pattern.
What is the difference in purpose between a function... |
I am looking for a software license which has stronger protection than AGPLv3. The GPL license said that when we distribute the software, we must provide a way for user to download the source code. However there is a loophole in this license, the GPL FAQ said (see below) it is not considered "distribution" if the compa... |
Scenario:
Two virtual machines produce logs. I want these logs to be sent to a central server for processing (as soon as a line of these logs is generated-->streaming ). The condition here is that I want the server to know from which virtual machine the log line came from. In the server, we should observe a file contai... |
Something that has long confused me is that so much software uses the terms "charset" and "encoding" as synonyms.
When people refer to a unicode "encoding", they always mean a ruleset for representing unicode characters as a sequence of bytes - like ASCII, or UTF-8. This seems reasonable and intuitive; the idea is that... |
I wrote a class to do something, but then realised that it wasn't needed, as I could optimize existing code to get the speed of execution I needed, rather than integrating the new class in with existing code (which would have been more complicated). However, I'm unsure if my current solution will be fast enough when I'... |
While developing a FAT32 driver for my bootloader, I thought to make it complete by adding the long file name support.
While watching around for some specification, and I also found
articles about Microsoft suing for infringement of their patents on something that basically is a workaround. Knowing about this events ... |
While learning SRP and LSP, I'm trying to improve the design of my code to comply best with both of these principles. I have an employee class that has a calculatePay method on it.
Firstly, I believe following OOP SOLID Principles, calculatePay() method should not be an employee objects responsibility. Common responsib... |
I built an ASP.NET MVC application, and now I want to move it to Amazon AWS from my development server. My question is: How does one migrate an ASP.NET application to Amazon AWS? Here is what I have researched/found so far:
Sessions don't work across instances, so I need to use DynamoDB or memcached to store state. I ... |
I'm using the MVC pattern in my web application built with PHP.
I'm always struggling to determine whether I need a new dedicated controller for a set of actions or if I should place them inside an already existing controller.
Are there any good rules of thumb to follow when creating controllers?
For example I can have... |
Suppose I have a GPL v2-licensed library that is of interest to a closed-source project (e.g. Wolfram Alpha).
If some of my code were used in Wolfram Alpha, or a product that interfaces with Wolfram Alpha, would they have to release all of their code for Wolfram Alpha under the GPL v2 license?
|
I want to find the oldest/newest element added into a heap of size k. At any given point of time if I have to find say the oldest element in the heap is there any approach with O(1) space and O(1) time.
I was thinking of an approach of having a queue of the same size as that of the heap and add all the element into the... |
I have a button that will be disabled until you send out a tweet that I have crafted.
Only users with twitter accounts will have access to this, and I will require users to sign-in to be able to access this button.
What kind of tools are available for me to check whether
The user has actually tweeted it
The user has ... |
I am thinking of a way to do collaboration between coders in a company, suppose we have 2 type of servers: Production and Staging. Now we want to review all changes going to Production via pull-request, at the same time, we want coders to be able to push experimental changes whenever they want to Staging. The objective... |
In my team, we work closely with a few software architects. They approve all design decisions of our projects, do some code reviews etc.
Our projects consist mainly of backend functionality implemented in PHP using the Symfony 2 framework. So syntactically, the code, naming conventions and project structure look almost... |
I have a LoginService class with loginUser($email, $password, $remember = false) method in the application layer of my model layer.
Now, if $remember is true it needs to create a persistent user login cookie on the client's browser, but since that is the responsibility of the View, what is a good way of reaching the vi... |
We have a database of resources, be they products, blog posts or something. We need to design a URL scheme to address them, for the public website.
Here are two examples that are database ID bound:
https://www.youtube.com/watch?v=7FPS6llqhXw
http://www.amazon.co.uk/gp/product/B000NHOMSQ
Here's an example that's frien... |
I'm looking for examples of creating, handling and managing error numbers/codes.
To understand what I'm takling about, let's take example scenario:
(EU - end user, IT - it helpdesk)
EU: - (calls IT) something's wrong
IT: - what happened?
EU: - it says "cannot create xyz"
IT: - what have you done?
EU: - ummm....
(conver... |
I'm creating a project and I'm having difficulty and contrasting opinions on how to do things when it comes down to separating layers. I'm not fully sure what layers should reference each other.
I have read in certain blogs/posts that the flow should be
the view references the business layer
the business layer referen... |
I have a custom file type .mft which is basically a zip that has video inside (mpg,mp4,etc) that is encrypted/protected.
My ideia is to create a custom video player which will read those .mft files, for a private group of users (users provide user and password), and the custom player will not allow to save the video, s... |
I stumbled across polymorphic engines and I don't know anything about them. However, I am curious about how they are written. Every example that I've looked up writes them in assembly, my assembly is not good at all; I know just a few instructions here and there but not that well. On the other hand, I am good in C and ... |
I am amazed by the way Github integrates with different systems like Travis. They are separate companies, but yet Travis builds blend seamlessly everywhere in the Github interface.
Yes, i am asking mainly about integration on the user interface level, there is enough electronic ink around about service integration.
Usu... |
Just ran across this term here:
http://www.codemesh.io/codemesh2014/viktor-klang
"We'll demonstrate the Flow API—a lifted representation—as well as a
pluggable way of transforming the lifted representation into the
execution representation—Flow Materialization."
Googling did not help much.
|
I am working on an Asp.NET MVC web application.
I have the following (simplified) entities:
public class Course
{
public int Id { get; set; }
public string Name { get; set; }
public string Description { get; set; }
public User CreatedBy { get; set; }
public EventArea EventArea { get; set; }
}
publi... |
I need to find an "efficient" data structure / set of algorithms to do the following things:
I have a list of objects. I need to assign them weights and later on increase or decrease these weights.
For instance:
We have the hashmaps {o1}, {o2}, {o3}. The {o}'s don't have any particullar structure, just random json.
I ... |
Automatic documentation generation can be done with a variety of tools, GhostDoc being one of the more prominent. However, by definition, everything it generates is redundant. It takes a look at names of methods, classes, etc. and outputs English that might explain them more verbosely. In the best case, it does what... |
I've inherited a web-based educational game. Over the past year I've worked towards stabilizing the code and adding new features. Most of the logic is in the front-end, so back-end unit tests, while helpful, cover a small percent of the code.
The game has gotten to the point where it's starting to get complex. There ar... |
I recently got a requirement to develop a chat-like application, or rather, a foundation of classes and methods that would allow certain applications to have chat-like features. The framework must be usable in at least two languages: Visual Basic 6 and C#.
If VB6-Application A were to transmit string data to CSharp-Ap... |
I've been struggling with this question for a while.
I'm specifically thinking within the object orientated domain model.
Let's say I have two entities. A supplier and a customer. There is a relationship that a supplier can have many customers, and a customer (in this case) can only have one supplier.
The issue I have ... |
I'm looking for an idea to efficiently solve following problem:
I have a set of pairs of ranges (range = a pair of numbers), each range is unique (but has same size) e.g.
[
[(0,6),(34,40)],
[(1,7),(35,41)],
[(3,9),(12,18)],
[(2,8),(36,42)],
[(13,19),(22,28)],
[(23,29),(14,20)]
]
Now I'd like to combine pairs ... |
How is runtime-generated machine-code (such as the output of a JIT), actually executed by the CPU if the CPU/OS has an Execution Disable bit?
As far as I know, many modern processors and Operating Systems include support for an NX bit, (including Intel and ARM), which prevents machine code that is stored at any address... |
We are planning to use a setup that uses several modules to complete a whole application, example modules include:
The core (code shared by all other modules)
The server
The client (Windows, OS X, Linux)
The client (iOS)
The client (Android)
Tool #1
Tool #2
And now while we preparing to deliver our first release, it ... |
Since HTML5 is still only a markup language, what is meant when people say "HTML5 application"? Please explain.
|
I'm struggling with how to keep track of what myself and people on my team actually do each day. I get a good broad picture by going over completed cards each week and stand-ups help a bit, but I feel like I don't have a good handle on the day-to-day workings of my team. Cards will stay in progress for days on end with... |
I'm developing an ASP.NET Web Api 2 RESTful web api with .NET Framework 4.5.1 and C# and I'm trying to understand how to expose resources through a Web Api:
Imagine that I'm a group owner and I am the only one that can add new users to that group (I'm trying to simulate a WhatsApp group).
This is my C# class for user:
... |
If you have multiple products that contain some shared components, how do you track dependencies to work out which other products a bug affects?
For example, product A, B and C use a CRC library module. A bug is found and filed in the module in product A. How can we assess that B and C are affected and need a bug fix r... |
We have a scrum team where there are 5 developers, 2 automated testers, 1 manual tester. Our tasks are completely independent.
Shouldn't there be 8 people, every one should be able to do every task: write code, write tests for it, sometimes manually test something?
|
I don't know if there are any accepted names for these patterns (or anti-patterns), but I like to call them what I call them here. Actually, that would be Question 1: What are accepted names for these patterns, if any?
Suppose there is a method that accepts a bunch of parameters, and you need to check for invalid input... |
We are designing an error-handling framework for a cryptographic library written in C.
The approach we are taking is that relatively few errors are propagated back to the user since on most occasions he cannot do anything about them (notable exception: parameter validation errors. Of course we tell the user if a call s... |
I have a web app product (PHP, MySQL) for which I offer a bespoking service. That is, you can buy the main product, which is quite extensive, and then have it customised however you like. This might include new features, adjusting fundamentally how existing features work, disabling features, making changes which requir... |
When answering a question on Stack Overflow, the library appeared to have a weird way to specify configuration, through an Action passed to the constructor:
public Parser(Action<ParserSettings> configuration)
{
if (configuration == null) throw new ArgumentNullException("configuration");
this.settings = new Pars... |
So far, I have used the MVP architecture pattern a few times. Every now and then, I wonder whether my Presenter should depend on my View or vice versa, that is the View depends on my Presenter.
NOTE
Though the sample code provided is in C#, I don't mind about the language. My question targets more precisely the MVP pa... |
I struggle with this every time I work on a project. I am not entirely sure what the standard conventions are for creating view ids. I usually use something like
view_more_button
but then if we have, let's say, multiple dialogs with a view more button then I'll start doing
view_more_button_dialog1
and from there it ... |
I'm willing, with some friends, to make a developers guide for an open source point of sale written in Java.
The thing is I have never written anyone and so I don't know exactly what to put in there to meet standards. I'm thinking about putting UML, and using Java doc but still I don't know what are the expectations of... |
I was told by a colleague that in Java, the performance may be worse if we create more methods, stacking many methods calling over them in JVM, specially in a Java EE environment.
This seems to somewhat defeat the concept of object oriented programming. Like if we write long methods - what isn't good for code readabili... |
I've been trying to understand C# delegates using Pro C# 5.
In short, the author describes the motivation for delegates as a structured way of dealing with function pointers and callbacks or two-way communication between objects.
The part I find confusing is the syntax/implementation for this:
On the one hand, an ob... |
So I've been doing some cross-platform mobile applications using cocos2d-x. Basically it uses common c++ code, that can easily be compiled to the popular mobile platforms with some small wrapper code that stays constant while working on the common c++ code. Everything works great, but I have a problem keeping all my ... |
Please say that 'code rots' if you don't clean it. What does that mean?
Obviously code is text, not an organism that can change itself. So why does code 'rot' if you don't touch it? What makes it 'rot' and what does it actually mean?
Please explain, examples would be welcome.
|
I'm taking intermediate data structures course as a prereq for entry into the CS MS program at a University everyone in America has heard of. One line of code that was written in class caught my eye:
if (a > 33 | b++ < 54) {...}
This would not pass a code review at my workplace. If you wrote code like this in an interv... |
Let's say we have an opaque type handle_t that is managed through a simple interface with functions such as:
handle_t *handle_init(void);
int handle_do(handle_t *);
void handle_free(handle_t *);
The problem is that the size cannot be always determined in the initialization step and it has to be calculated in handle_do... |
In an answer to a previous question, a small debate started about correct terminology for certain constructs. As I did not find a question (other than this or that, which is not quite the right thing) to address this clearly, I am making this new one.
The questionable terms and their relationships are: type, type const... |
I read on the wikipedia article for Common Language Runtime that one of the benefits that the runtime provides is "Performance improvements".
Executing managed code (Or bytecode) must surely always be slower due to additional overhead for JIT compilation than executing native code. How then is it possible that the CLR ... |
Let's say I have to generate random number from 1 to 100, however, the probability of each number is not 1/100, but a predefined probability.
How to generate that number? I use Ruby/Python.
|
Why did the creators of the Internet Protocol decide to use IP addresses to identify a particular computer?
Why not just have a unique ID assigned to each computer upon manufacture, then use that ID for identification of the computer?
|
Your client/user declares he has absolutely no intention of being available frequently throughout a project, just enough to say "I want the application to do this" and answer a few questions every month or so. Also, the idea of having to define priorities story by story makes him scream...
Yet, on all the projects you ... |
I am building a .NET 4.5 C# Web API RESTful solution and I would like someone to tell me if my project solution is correct and/or wise(-enough?) for a solution designed using Domain Driven Design, please.
The solution has been split into 6 projects:
/Base
(Not referenced by anything)
The web project and forms the int... |
Producing predictable output for each possible input is the responsibility of each module. For example (in C#):
class Logger
{
public ITextWriter Writer { get; set; }
private uint counter;
/// <summary>
/// Writes message in special format and returns the number of total messages written
/// </sum... |
I have built an android game - I would like to add a "high score" leaderboard to it, such that people can show off how high they managed to score. How should I design it so that people can't "hack" it by decompiling it and sending a fake score? I don't believe android has a TPM module yet for most devices, so I can't s... |
We wrote a simple .NET (C#) desktop application in Wpf. We also used WIF (Windows Identity Framework) to get a list of claims for the authenticated user. Some examples are:
CanOverrideSalesAmount
CanAddContact
etc.
This works fine and all, the client seems very protected. But, when I was debugging the application it ... |
I am currently implementing a class for a network protocol. The protocol uses a quite complex and extensive finite state machine. A pair of an event plus a state is mapped to a function, which does some work and sets the new state.
As there are about 150 valid state/event combinations and 28 distinct functions to be c... |
I am in the process of trying to sell my organisation on the value of code reviews. I have worked at several places where they were employed. I have seen them used to nitpick styling choices, and functional decisions, and I have seen them used as nothing more than a gut check to make sure nothing dangerous is being i... |
I have three childViewController views inside my ContainerViewController and these three views are inside a horizontal scroll view. My intention is to build an app that has a custom camera on one ChildViewController view, a tableView which will display JSON data on another view, and a page which will show a list of the... |
I have a public website that does not require authentication. It's a lighting calculator for indoor cultivation. Anyone can enter and complete the process and ultimately save your settings for future use sharing it on Facebook or twitter.
The configuration is saved as a document in a database, using a REST api. At th... |
So I am working on a solo project that involves a lot of strings. In one of my smaller test cases there will be at least 70 million elements. So my question is, what is the largest possible size a TreeSet or a HashSet can reach until it can no longer grow OR until it reaches a size that it can no longer be feasible to ... |
If I use an Open Source library which is released under a zLib like license, but it has dependencies on libraries that are using LGPL or GPL; what license am I able to release my project under?
If I read things I find on the net it sounds like I can sell my project but I can't stop people from distributing it freely as... |
I am creating a simple blackjack game backed by database
In my Card is
public class Card{
private Face face;
private Suit suit;
//setters.. getters
}
where face and suit are enums
I have an entity Bet with the following
@Entity
public class Bet{
private Player player;
private String cards;
//...
}
Curren... |
I'm beginning to study OOAD and I'm having difficulty finding a C++ code example that'd illustrate how Association, Aggregation and Composition are implemented programmatically. (There are several posts everywhere but they relate to C# or java). I did find an example or two, but they all conflict with my instructor's i... |
Please can someone explain to me how I should go about deciding whether to use expect or should syntax for my rspec examples.
From my understanding we should no longer be using the 'should' syntax.
The replacement is to use expect().to or is_expected.to
Is this correct?
On some really good references, it seems to be co... |
I have the following coding environment:
Three Developers
Source code resides in Team Foundation Server (2010)
Development Environment
Stage Environment
Production Environment
As the Senior Developer, I need to review code before its pushed to the Staging Environment. Once I review the code, it is pushed to Stage whe... |
I am trying to create a sports league scheduler. I am having trouble identifying an algorithm to help me efficiently fill in each slot.
Sample data to build the schedule would be:
10 teams
Each team plays each other 1 time (45 total games
required)
Each team plays no more than 1 time per day
In my testing I am using ... |
Let's say I have a database-driven web application written in PHP.
After obfuscating the code with PHP protect it will
be copied to a web hosting server.
And here is the question.
What is the workflow of a programmer when there is a bug in an application
and he needs to edit the PHP code to repair it?
It's clear, that ... |
in my repository I've got a sw and a cfg(config) folder under trunk, I'm thinking that when I release I'll branch both of these to the releases folder e.g. v1 of my app, with London config data. If I want to release v1 of my app to NewYork too then I'm thinking I'll branch my config data off of main and adjust it in th... |
Google has an advanced diff tool specifically designed for compiled binaries called Courgette.
Is there any reason why they wouldn't use this in Android and the Google Play Store to download updates? In my basic understanding of Java, it seems like it shouldn't be any more difficult (perhaps even easier?) to create 'di... |
I am involved in an open-source project with multiple copyright holders. The project is licensed under the 3-clause BSD license. Unfortunately, the individual code files contain no reference back to their original owners (no copyright headers), but for the project as a whole a single file LICENSE.txt, which contains t... |
Basically, I have code that looks like this. It's a typedef and a set of methods that revolve around that typedef.
class foo {
// Foo stuff...
// Registration Stuff
private:
typedef std::map<std::string, std::string> MTRegistrationParams;
void DispatchRegistrationMessage (MTRegistrationPa... |
For comparison, for a runtime fatal error, it is often that the cause of the error is way before the error crashes a program.
For a logic error, it doesn't crash a program. It happens when the state of the execution of the program isn't what we expect for the first time. The cause of a logic error in a program, I think... |
I have searched extensively for a similar Mongo schema design and can't find relevant examples.
I have a store (with public info), each store has an account (with private account info).
// store object
{
name: "Departement Store",
email: "contact@store.com",
account: { // private info not returned by API
mana... |
NOTE: The language I am using is C#.
I am currently working on a 'The Quest' mingame where there is a player and some enemies.
My design so far involves a base abstract class called 'Mover' and an interface called 'IAttacker', since the Player object and the Enemy object(s) both move and attack, albeit in different way... |
Macros exist in many programming languages, for example, C.
A data type is a set of values with operations on the values. Are
macros values, or data types?
Are macros identifiers, variables, or constants?
Are macros something not belonging to a programming language,
and something that will be translated to the program... |
I am trying to implement a recursively defined Stack and sort it in Java.
I don't have a particular usage of this program in mind. I found this approach of stack implementation a bit useful while implementing persistent stack.
I know Stacks are not made for sorting but one can consider using two stacks to implement a j... |
(1)
The oldmakeutility looks at timestamps, and if the output is newer than the input, it skips (pointless, time-consuming) re-compilation of e.g. C files.
The same is true for many languages and compilers. “Lazy” thumbnail generation in web aplications skips those thumbs that are newer than the source image.
“Smart”... |
I just found this function in the project I'm working at:
-- Just returns the text unchanged.
-- Note: <text> may be nil, function must return nil in that case!
function Widget:wtr(text)
return text
end
Too sad, the coder does not work in the company anymore. Why would one make a function that does nothi... |
The idea is that I have a set of properties that represent possible options in the app. These options can be modified through a variety of different ways, such as from the UI, remotely, third party, etc...
Each time one of these modifiers alters the state, the other modifiers need to be notified. E.g.: If the user mark... |
What is the preferred convention for structuring view model properties? It is better to use generic or more specific property names?
Let's have a user, the page where this user will be displayed should be altered by user's permission. The view model could be written in two different ways:
{
userName,
userEmail,... |
Question: In java application, How to change error message or simple alert text without redeploying / restarting application
Closest answers I could think up (1) is to have a new error messages in specific file in specific location say "\root\resources\messages.txt"and to create a file object for it like.
File msgFile... |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.