FAQ Database Discussion Community


Where is the best place to put support functions in a class?

python,class,design
In Python, I have a class that I've built. However, there is one method where I apply a rather specific type of substring-search procedure. This procedure could be a standalone function by itself (it just requires a needle a haystack string), but it feels odd to have the function outside...

Approach for designing a program that generates a flat file from dozens of queries [closed]

oracle,design-patterns,stored-procedures,design,plsql
There's a federal program called COBRA that provides the option of continuation benefits to employees who lose coverage based on several lost coverage reasons. We pay a vendor to send out the communications to employees when they have a COBRA qualifying event, so we have to generate a file every...

Java oop inheritance and interfaces

java,oop,design
I have few questions related to oop in java. I understand that is-a relationship means inheritance. I understand that can do relationship means I need to implement interfaces. Problems arise here : Now, if I have more variables eg: in class Square -> int side; in class Rectangle -> int...

Web Design - What is that style?

javascript,html,css,design,web
I was wondering if there was a name for this 'style' of web design (sorry, these are the only examples I could come up with atm): http://www.apple.com/watch/?cid=wwa-us-kwg-watch-com http://www.codecademy.com/ I see it used frequently and want to try to do something similar as an excercise. The style is very vertical and...

How to model data for in-memory processing

java,performance,design,architecture,data-modeling
I have a lot of static data (i.e. read only data, which is not transactional) which gets updated only once in few days. I have to support searches on that data (api calls, not sql). So I am thinking I will just load it in Memory, and refresh the in-memory...

Does 'api/SomeEntity/ForOtherEntity/{otherEntityId}' break REST?

rest,design,web-api
Using the example of facebook users having a collection of photos, if I'm designing a RESTful API for the photos, these will have GET/POST/PUT/DELETE endpoints for the photos themselves, is it breaking REST or a design patterns to have a get by user id? e.g. GET Photos/ //gets all photos...

Attr value is declared in two different libraries

android,design,attributes,styles
I added a library to my project in Android Studio. But as soon as I tried to compile my project I got this error: Attribute barColor has already been declared. After that I checked the whole project and noticed that another library is already declaring that same attribute! How can...

Search box/field design with multiple search locations

python,search,design,search-engine,pyramid
Not sure if this question is better suited for a different StackExchange site but, here goes: I have a search page that searches a number of different type of things. All (at the moment) requiring a different input field for each type of search. For example, one might search for...

Define utils function available for all views in angularjs

angularjs,design
I have a few functions I would like to be available in all my views (like utils functions). Where should I put them ? Is it better to add them to all my directives, or to a common directive ?

Dynamically-Allocated Implementation-Class std::async-ing its Member

multithreading,c++11,asynchronous,design,shared-ptr
Consider an operation with a standard asynchronous interface: std::future<void> op(); Internally, op needs to perform a (variable) number of asynchronous operations to complete; the number of these operations is finite but unbounded, and depends on the results of the previous asynchronous operations. Here's a (bad) attempt: /* An object of...

segfault in critical section - avoiding deadlock

c++,c,multithreading,design,deadlock
I am asked following question in an Interview: 1) There are two threads: T1 and T2. They are sharing one resources and to avoid deadlock using pthread_mutex for synchronizing. How you will design your code such that if any segmentation fault happen after T1 enters critical section, T2 will not...

Responsive web design tester vs. actual devices [closed]

design
I have tried my website on multiple responsive web design testers. The design is collapsed on some devices including iPhone 5, iPhone 6, and some Android phones when I test the site with testers. However, the design looks fine on the actual devices listed above. I was going to fix...

How to avoid anemic data model? Can repositories be injected into entities?

java,oop,design,domain-driven-design
I have an immutable User entity: public class User { final LocalDate lastPasswordChangeDate; // final id, name, email, etc. } I need to add a method that will return information if the user's password must be changed i.d. it has not been changed for more than the passwordValidIntervalInDays system setting....

Design pattern for corner-case logic without switch and conditional statements

java,design,notifications
I have a class with many switch statements in it. The code looks very ugly to me but I can't figure out how to fix it. If somebody could suggest a design pattern or a trick that cleans this up that would be great. Below is a abbreviated version of...

Match status bar colour with most predominant colour of art Material Design Android

android,design,whatsapp,material
I was wondering if there was some kind of library/api or way to match the status bar colour with some imagery just like in the Whatsapp material design update. Example here and here. Thanks in advance!...

NoSql beginner dude. Data design and relationships

database,design,nosql
I have many doubts NoSQL concepts. I can understand how NoSQL data store, but do not understand how to deduce the best way and how to distribute the data. For example, a data store. How to store the orders? Option A: customers: [customer {data1, data2,..., orders: [{data1, products [{data1, data2,...

How can I achieve this design

css3,design,responsive-design
http://www.awwwards.com/websites/single-page/ It's called bad assembly, located at the bottom of the page Okay so I'm trying to achieve the design (desktop view) you see above but my pictures keep overflowing. I could just hide the overflow-y but I don't want to do that. My Css is just boostrap, by the...

How to make java interface / abstract class that uses per-field equals instead of default equals?

java,design,hash,equals
I have a process which requires creating java classes which will serve as keys in a table (as a key in a Spark framework). To get the correct functionality, I need to override the default object equals() and hash code methods with functions that perform field-wise comparison. (I generate this...

How to design a dependency list and store it

c#,sqlite,design-patterns,design
I am working on a game which as a series of quests. There are many quests available to the user at any time, however certain quests depend on others being completed first before they are available. You can look to WoW for possibly the best implementation of this. As you...

Implementing a Command Design Pattern with static methods C#

c#,design-patterns,design,static
I know how to implement a Command Design pattern as follows: public abstract class Command { public abstract void Execute(string someString); } Say I inherit this ,as an example: public class ConnectionCommand : Command { public override void Execute(string connectionString) { ...do some stuff here...; } } Problem is to...

Getting started: Android application design [closed]

java,android,design
I want to create game on Android (it will be 2D board game), but I haven't got any ideas, how to design it, namely what tools (librares, engines, etc.) to use. Source code language is Java. I hope that somebody has some experience in this field and will help me....

I can't Run my website [closed]

php,mysql,design
Deprecated: mysql_pconnect(): The mysql extension is deprecated and will be removed in the future: use mysqli or PDO instead in C:\wamp1\www\ShareRoot\Connections\Share.php on line 9

How to assure two vectors which will be passed in constructor size equals?

java,exception,design,constructor
I implemented a class: public class TableInfoGroup { Vector<TableInfo> tableInfoVector; public TableInfoGroup(Vector<String> tableNameVector, Vector<String> tableTagIdVector) { if (tableNameVector.size() != tableTagIdVector.size()) return;//I think it's not proper to do this tableInfoVector = new Vector<TableInfo>(); for(int i = 0; i < tableNameVector.size(); i++) tableInfoVector.add(new TableInfo(tableNameVector.get(i), tableTagIdVector.get(i))); } } How to do that elegant?...

Design suggestion: Changing the class behaviour

java,design,object-oriented-analysis
Below I am trying to explain the problem with an example. We have a Caller.java Caller.java : which calls the series of Actors to perform certain steps in sequence. Actor.java : Abstract class containing action() method ActorOne.java : Implements the action() method ActorTwo.java : Implements the action() method ActorThree.java :...

Avoiding semantic coupling with Java Collection interfaces

java,algorithm,oop,design-patterns,design
These days I am reading the Code Complete book and I've passed the part about coupling-levels (simple-data-parameter, simple-object, object-parameter and semantic coupling). Semantic being the "worst" kind: The most insidious kind of coupling occurs when one module makes use not of some syntactic element ofanother module but of some semantic...

What should DELETE /collection do if some items can't be deleted?

rest,design-patterns,design
I have a collection of items and some of them may or may not be deleted, depending on some preconditions. If a user wants to delete a resource (DELETE /collection/1) and there are external dependencies on that resource, the server will return an error. But what should happen if the...

How to enable Design View in jsp file in Web application project in Netbeans?

jsp,java-ee,design,netbeans,web-applications
I'm working on a Web application project and I've added a jsp file but I can't see the Design View. I don't know if this feature has been removed in new versions, but here here's a pic of Design View in a jsp: How do I enable it? thanks....

How can i create the basics of a GUI? [closed]

java,user-interface,design
I have this code sample : import javax.swing.*; import java.awt.*; public class MainApp extends JFrame { public static void main(String[] args) { } } I want to create a window with specified resolution, give a title and create the environment for other GUI methods. How can i do that ?...

What should be returned from the API for CQRS commands?

rest,http,design,cqrs
As far as I understand, in a CQRS-oriented API exposed through a RESTful HTTP API the commands and queries are expressed through the HTTP verbs, the commands being asynchronous and usually returning 202 Accepted, while the queries get the information you need. Someone asked me the following: supposing they want...

Subtypes of an interface only compatible with a subtype of another interface

oop,design-patterns,design,architecture,solid-principles
I've been scratching my head for a long time on a problem and I still don't know what would be the best solution. Since the application domain is very technical, I'll illustrate my problem with a simple example. Suppose I have the following interfaces: public interface Animal { public void...

Passing control of a drawing window “deeper” into a program?

c++,design,graphics,sfml
I am using SFML 2.3 to control the graphics in my program. I need a class to be able to access the window, to draw to it even if that class was not the one that originally created the window (does not have ownership). E.g. the Battle class needs to...

How to get bar click event from horizontalbar charts of MPcharts in android?

java,android,design,mpandroidchart
I am using MPAndroidChart library. I have used Horizontal bar charts in my dashboard. I want to navigate to another activity by clicking particular bar of that chart. How can i do this??...

Android App - Designing for HTC Nexus 9 Screen Resolution

android,design,tablet,screen-resolution
I've designed my app for mobile phone devices, but the sizes and resolutions of many of my images look horrible while displaying on an HTC Nexus 9 tablet. What is the required width (in pixels) for my images so that they fill the screen properly (assuming the image is filling...

what is the difference between view and container view in iOS design?

ios,user-interface,design,uiview
I was trying my hand at Xcode lately and i came across the view and the container view. I was not able to figure out the difference. Can anybody explain it to me.

Java 8 way to work with an enum

java,design,enums,java-8
I'm wondering what the best way is in Java 8 to work with all the values of an enum. Specifically when you need to get all the values and add it to somewhere, for example, supposing that we have the following enum: public enum Letter { A, B, C, D;...

Best way to write a Java function that modifies an object

java,design
I'm currently moving from C++ to Java for work and am having difficulty without const and pointers to make sure intent is always clear. One of the largest problems I'm having is with returning a modified object of the same type. Take for example a filter function. It's used to...

How to implement solution for Race simulation problems

algorithm,design-patterns,design,data-structures
There was a question asked in an interview: In a Formula-1 challenge, there are n teams numbered 1 to n. Each team has a car and a driver. Car’s specification are as follows: Top speed: (150 + 10 * i) km per hour Acceleration: (2 * i) meter per second...

Can we use Windows 10 (for phone ) model design in Windows phone 8.1 App?

design,windows-phone,windows-phone-8.1,windows-10
I am developing an app for windows phone 8.1 . Based on MSDN design guidelines I am using pivots and panorama controls in my application. I heard there are some significant changes in UI in windows 10 OS and MSFT is not using popular controls like pivot and panorama in...

Custom shape of a SeekBar in android application

android,design,android-seekbar
I know it is possible to change the style of the SeekBar in android apps, but is it possible to change the shape of the progress line of a SeekBar? I would like it to be like that: Any ideas on how to achieve this? :)...

Be suspicious of classes of which there is only one instance

oop,design,code-complete
tl;dr -- What does the below quoted paragraph mean? Be suspicious of classes of which there is only one instance. A single instance might indicate that the design confuses objects with classes. Consider whether you could just create an object instead of a new class. Can the variation of the...

How to refactor a singleton class and avoid doing the same mistakes again

c#,design-patterns,design,singleton,static-classes
I've started a small application in WPF and used a Singleton class to handle all the application logic. Plus I had a few ObservableCollections there that are binded to DataGrids on the View. The problem: what was supposed to be a small program started to grow in functionality and the...

Multiple if statements modifying private fields

java,if-statement,design
I have a class A defined as follows in Java: public class A { private String fieldName; private String detailFieldName; private String externalFieldName; private int formatLength; /* additional private members */ void setProperty( String aPropertyName, String aPropertyValue ) { try { if( aPropertyName.equals( AField.FieldName.getName() ) ) { fieldName = aPropertyValue;...

Should a class that will run only once contain a static constructor?

c#,oop,design,constructor,static-constructor
I am beginning to learn OOP programming with C#. Concerning design, it makes sense to me to use a static constructor for the main class of my program, considering this class contains code that will run only once (my whole program is very simple and consists of a single .cs...

Updating composite entities in a RESTful resource

rest,design,restful-architecture
I have an entity with several attributes, say «project». Apart from simple attributes, the project may have a list of «statuses» of which the last one is the current one. I have a web form to create/edit a project. All attributes of this project can be changed in this form,...

Base Class for multiple classes in different projects

c++,inheritance,design
This is more of a design question. Currently I have multiple classes (in different projects) which have different roles but there is one common method which performs the same duty. I was thinking about having a base class for all theses classes so each of them could inherit this class...

Why not reveal the type and identity of the source to the client?

c#,linq,security,design
On page 220, the C# Language Specification Version 5.0 says: It is important ... to ensure that the result of a query expression is never the source object itself, as that would reveal the type and identity of the source to the client of the query. Why would it be...

Should one forward declare classes from a namespaced library?

c++,design,namespaces,forward-declaration
I'm designing a C++ library that will be placed inside a namespace. If the users of my library only need a forward declaration of one of my classes and since you can't do forward declarations of things inside a namespace, e.g. class ns_name::class_name;, should I tell them to include the...

Q: I need idea to display a string with css, jquery or any other techniques (no php)

php,jquery,css,design,styles
I have a big problem. I have a mysql database which contains 12 character length fields. I would like to display somehow. Sample data from the field: 233215334523 I would like to display 0 and 1 with red background 2 3 with yellow background and 4 5 with green background....

Are calculated quantities a part of the Model, View or Controller?

java,model-view-controller,design
Say I have a Model-View-Controller type application. The model is a car with an engine and tires etc. The speed of the car is a derived/calculated non-persistent quantity that depends on the engine and tires. Should the speed be a part of the model? Or should it be a part...

css div gradient shadow/border

html,css,css3,design,shadow
I am trying to achieve this: I couldn't find anything like it, but here is my failed attempt: #one { width: 200px; height: 100px; background-color: white; box-shadow: 0px 0px 20px #2D8DBD; left: 50px; display: inline-block; margin-right: -100px; } #two { width: 200px; height: 100px; background-color: white; box-shadow: 0px 0px 20px...

Java: Classes do not find each other in package (factory design pattern)

java,design-patterns,design,factory
I have three different classes: Woman.java package human; public class Woman extends Human{ private final String pnr; private final String namn; public Woman(String n, String p){ namn = n; pnr = p; } public String toString(){ return "My name is "+namn+" and I am a woman."; } } Man.java package...

Sending and receiving data over Internet

sockets,design,data,send
This question is not for a concrete implementation of how this is done. It is more about the concept and design of sending information over Internet with some kind of protocol - either TCP or UDP. I know only that sockets are needed, but I am wondering about the rest....

What's the principle to define an interface with dependencies?

java,design,inversion-of-control,method-signature
Which dependency should locate in a method signature as a param and which should not? Since we have IoC container like spring, most of the dependencies could get injected through it. For java.util.concurrent.Executor: public interface Executor { void execute(Runnable command); } The interface could be public interface Executor { void...

C++ Avoiding down-casting or variants

c++,design,variant,downcasting,visitor-pattern
I've been facing a design issue for a while : I am parsing a source code string into a 1-dimensional array of token objects. Depending on the type of a token (litteral, symbol, identifier), it has some token-type-specific data. Litterals have a value, symbols have a symbol type, and identifiers...

How to handle this cycle dependency?

javascript,design-patterns,design
I have an design like this: UI Layer Component Layer. The idea is all event handlers like click, painting the dom will be hitting UI layer, which will call the corresponding component layer. Now imagine on click of a button, the ui layer calls component layer, so the dependencies looks...

For a data member, is there any difference between dynamically allocating this variable(or not) if the containing object is already in dynamic memory?

c++,design,stl,smart-pointers,c++14
I'm starting with the assumption that, generally, it is a good idea to allocate small objects in the stack, and big objects in dynamic memory. Another assumption is that I'm possibly confused while trying to learn about memory, STL containers and smart pointers. Consider the following example, where I have...

How to design Validator class in regards to SRP? [closed]

php,design,solid-principles,srp
Is it better to have a validator class which have methods such as validateUrl(), validateEmail(), validateInt(), etc ? Or, URLValidator class, EmailValidator class, and INTValidator class ?

What does overflow mean in this case?

android,design,android-actionbar
I came across this during my android training : Specify the Actions in XML <menu xmlns:android="http://schemas.android.com/apk/res/android" > <!-- Search, should appear as action button --> <item android:id="@+id/action_search" android:icon="@drawable/ic_action_search" android:title="@string/action_search" android:showAsAction="ifRoom" /> <!-- Settings, should always be in the overflow --> <item android:id="@+id/action_settings" android:title="@string/action_settings" android:showAsAction="never" /> This...

How to Edit files using web application

design,web,jython
All, I have a requirement where user would like to edit the files using web application. I know there would be a concurrency issues. But i want to know if there is a way to do it efficiently in the web application, may be using Jython or any other framework....

Django object composition with OneToOneField

python,django,design,orm
As noted in other questions, Django experts like Two Scoops recommend explicit OneToOneFields rather than multi-table inheritance to avoid performance penalties of implicit joins. I have tried to follow such an approach, and my design is actually object composition, but have a few questions. All three of these are concrete...

Flot Bar Chart design

javascript,design,bar-chart,flot
I've made this bar chart http://imageshack.com/a/img901/7186/cnOfhh.png, and the code for it is: //compute & mark average color for (var i = 0; i < zdata.length; i++) { if (zdata[i].TargetTime == null) zdata[i].TargetTime = 0; if (zdata[i].TimePlayed == null) zdata[i].TimePlayed = 0; if (zdata[i].TargetTime >= zdata[i].TimePlayed) { zdata[i]['Color'] = 'green'; }...

Should I be attempting to return an array, or is there a better solution?

c++,arrays,design
A problem set for people learning C++ is Write a short program to simulate a ball being dropped off of a tower. To start, the user should be asked for the initial height of the tower in meters. Assume normal gravity (9.8 m/s2), and that the ball has no initial...

Avoid Type Casting During Data Processing

java,oop,inheritance,design,casting
I can't seem to figure out the best approach to tackle the following problem. Let's say there is an abstract base class with several concrete subclasses: public abstract class AbstractType { /* common properties */ } public class TypeA { /* properties of type A */ } public class TypeB...

Employee and Customer = People Table?

mysql,database,design
Is it bad to store information such as: name, phone number, address etc. in one table? That would result in the Employee and Customer Table having a foreign key referencing to the "People" Table. If we don't store such information in one table, we would have the Employee and Customer...

CodeBlocks C++ using Classes

c++,oop,design
Hey guys can you please check my codes below? It's just a simple calculator. I would like to ask what is the problem with this. I get error "Line 4. error: expected unqualified-id before ')' token #include<iostream> using namespace std; class Calculator() { public: int AdditionFunction(float num1, float num2) {...

Generate CSV test data at random from template

design-patterns,design
I am going to have to generate many CSV files that will contain random-ish data. There will be rules about the fields, such as some will be integers, some should be names picked from a particular list, some will be text generated from a Markov chain with a given source,...

Does a method like getMyClassOrNewClass violate SRP?

java,design,srp
I implemented something like that: public static void main(String args[]) { // that code below repeat many times MyClass myClass = getMyClass(); if (myClass == null) myClass = newMyClass(); } These three lines repeat so many times so I refactored it to that: public static void main(String args[]) { MyClass...

Setting Full Width to WPF Image in C#

c#,wpf,design,resize
I'm trying to reduce my window size to 70%, in which there will be an image that will be stretched for 100% width and 30% (below the image) height, in which there is a stack panel containing some controls. <Window x:Class="CapManageR.Video" xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation" xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml" Title="Video" Height="500" Width="1000" Loaded="Window_Loaded" Closing="Window_Closing"> <Grid Name="grid1">...

SQL Naming Convention for ID that joins two tables

sql,design,naming-conventions
Im using camel casing for my column names and im trying not to use just ID for the primary key of my tables. So it seems stait forawrd for some tables like. Profile Table I call the primary key profileID but what about a table that joins two tables together....

Is call_user_func_array the way a page is served in PHP frameworks?

php,model-view-controller,design,frameworks
I wrote a small framework, but I am studying others. They are big, so I'm still trying to grasp their design. When a user calls the controller or router, is call_user_func_array the typical way the page is "handed off" to the renderer? I tend to see this type of thing...

How to remove white space between border and BackColor?

c#,winforms,design
I was wondering if there is a neat workaround with these white lines (white space) between border and BackColor? I have never really put much attention to these things before, but now it is starting to annoy me. Is there an easy way to remove this white space? Is this...

Web api: Retrieve m2m model vs Retrieve main model

design,views,models,m2m
I have a code-design question. Lets say we have a web app with a web service (rest api) and the models User, Job and also JobFavorite. JobFavorite model is a m2m model with fields user and job, meaning that a user can mark a job as favorite. Lets say that...

How to design abstract listener and its implementation?

design-patterns,design,template-method-pattern
I have decided to split my application into 3 separate modules - one "abstract" with almost all application logic (anyone looking at the code can tell WHAT it does), one "implementation" module with all specific implementation layers (like db, connections, etc) and one small "runtime" module that maps implementation with...

How to store text in a website? [closed]

php,html,design,web
I was wondering if there is a better way to keep website text independent of the site's layout. If i enter my text directly into the html or php file, there would be a lot to worry about when changing the site's design. Storing it in a database would have...

In jOOq, why is the connection highly coupled with the statement construction?

java,performance,design,jooq
Let's say I have a query builder ResultQuery query = DSL.select().from(TABLE); and a connection/context pool DSLContext ctx = DSL.using(conn, SQLDialect.MYSQL) I want be able to : reuse the same query object for different connection/context if the same query instance can't be use, use the query as a template execute the...

Designing layout android

android,layout,design,linear
I am currently trying to create a list view which will show details about a post. For that, I have created xml file for designing the list item. This is the final look I want for my activity. So far I have succeeded dealing with the rounded corners, image buttons...

Java immutability when defining members in a function called by constructor

java,class,design-patterns,design,immutability
I have class like this: abstract class Parent { protected Parent(Raw rawData) { deserialize(rawData); } protected abstract void deserialize(Raw rawData); } class Child extends Parent { final byte firstByte; public Child(Raw rawdData) { super(rawData); } protected void deserialize(Raw rawData) { firstByte = rawData.getFirst(); } } So basically any child class...

design rule ios app. Is own design allowed or rejected

ios,design
I have a question regarding design guide lines for an ios app. I would like to have my own design and I am not sure if this would be rejected by Apple when uploading to the store. So I would like to have opinions from expirienced IOS developers. I like...

Disable _notes folder that Dreamweaver as a IDE

design,dreamweaver
I use Adobe Dreamweaver as an IDE...I know the horror. It has worked well for many years and in code view. I don't need the power of Eclipse or have a mac so anyway the latest release has so non-funtioning settings on my pc. I disable Maintain Sync Settings and...

Designing a high performance network logger solution for a busy server

performance,sockets,networking,design,udp
I have a highly busy server that keep send/receive massive amount of data through the network, we currently write all the server logs to the same file system where the server is installed and that is causing us to get insufficient disk space after only 1 hour, that file system...

How to eliminate repeat code in a for-loop?

java,design,dry
I have implemented two member functions in the same class: private static void getRequiredTag(Context context) throws IOException { //repeated begin for (Record record : context.getContext().readCacheTable("subscribe")) { String traceId = record.get("trace_id").toString(); if (traceSet.contains(traceId) == false) continue; String tagId = record.get("tag_id").toString(); try { Integer.parseInt(tagId); } catch (NumberFormatException e) { context.getCounter("Error", "tag_id not...

Where to populate data? Inside or outside method?

design,data
I have a dilemma on where to populate the data. Below are 2 kind of methods to compute the total price of a quotation: // example in javascript function computePrice(quotation) { var totalPrice = 0.00; var items = quotation.getItems(); for (var i = 0; i < items.length; i++) { totalPrice...

Modern webdesign and effects?

layout,design,contao
I found this template: http://preview.premium-contao-themes.com/quantumflat/demo/blog.html Now I Was wondering, when I scroll down, the navigation resizes und stays fixed, how can I do this. And when i resize the browser, the boxes in the content area are resizing and reanranging as well, how can I do that? Thanks in advance...

Passing Variables to a Golang Package

design,go,singleton
Given a package containing the following local variable and functions: var bucket *gocb.Bucket func Init(b *gocb.Bucket) { bucket = b } func DoSomething() { // do something with 'bucket' } Is it acceptable to call the Init function, passing in an instance of bucket, before calling DoSomething, which is dependent...

designing “pretty” user controls [duplicate]

c#,wpf,design,charts,user-controls
This question already has an answer here: Creating a WPF Custom Control 2 answers I would like to create a user control which represents a pie chart and offers some mouse-over (tooltips / highlighting) and on-click events for the different parts of the chart. However since i can not...

Horizontal line with fade out effect

css,design,less
I'm trying to replace bootstrap <hr /> with a gradient looking line like this one. So far I've tried used this mixin: .horizontal-gradient (@startColor: #eee, @endColor: white) { background-color: @startColor; background-image: -webkit-gradient(linear, left top, right top, from(@startColor), to(@endColor)); background-image: -webkit-linear-gradient(left, @startColor, @endColor); background-image: -moz-linear-gradient(left, @startColor, @endColor); background-image: -ms-linear-gradient(left, @startColor, @endColor);...

Good Tutorials for iOS UI Design and Patterns [closed]

ios,user-interface,design
Can you please mention a good tutorial for iOS UI design? I have seen Apple documentations (https://developer.apple.com/library/ios/referencelibrary/GettingStarted/RoadMapiOS/DesigningaUserInterface.html). But, it would be nice to learn from a step-by-step tutorial (example one for Android: http://www.vogella.com/tutorials/Android/article.html). Note: Pointers to other SO answers would also help....

Is checking of object type really always sign of bad design?

c++,design,types
I have a source of some lines of text, each of which is a message, representing object of some type. I'm making a parser for these lines, which should take the text line as input and give the ready to use object as output. So I make the following hierarchy...

Singleton events

c#,events,design
I am refactoring some old code, where I have a lot of static events like this public static event Action Updated; public static void OnUpdated() { if (Updated != null) Updated(); } I found out what using lazy singletons is often better than using static classes: no memory is consumed...

Mixing DAO and service calls

java,design,architecture
Let's say we have some layer above service layer, with web controllers for example. Service layer is in turn above DAO/Repo layer. In the upper layer the service calls are used alongside repo calls. It breaks the layering of the application to some extent, but should we really bother about...

Runtime set property from a string

c#,vb.net,winforms,design,runtime
I have a string stored in database as 'GridColumn1.Caption = "XYZ"' Is there a way to execute this code in runtime (on windows form load) to set GridColumn1's Caption property to "XYZ" in vb.net or in c#? I want to read it from db on form load and set the...

Can I achieve ordered processing with multiple consumers in Kafka?

design,message-queue,kafka
In Kafka, I have a producer queuing up work of clients. Each piece of work has a client ID on it. Work of different clients can be processed out of order, but work of one client must be processed in order. To do this, I intend to have (for example)...

C++ - need advice on how to properly design a multi-file program

c++,design,header-files
Ok, so basically I need to create a simple game using Allegro 5 and C++. I want to split it into separate modules so it's easier to manage. My question is: what is the proper way to manage "moving" between different files? Specifically, I'd like to have a file called...

Change BackColor of ToolStripItem on Mouse Over [duplicate]

c#,winforms,design,contextmenu
This question already has an answer here: How to change Menu hover color - WINFORMS 2 answers So I have a MenuStrip in C# which I am trying to do a darkish theme for, but when I press the button for the dropdown menu well.... Is there a way...

Best approach to implement this design [ios]

ios,uitableview,design,grid,uicollectionview
What would be the best approach to implementing a design like the one below? Couple of things: Level cell can fall between any 4 cells on the grid Whole board is scrollable I'm leaning toward UICollectionView but I'm not exactly sure how to do the "level cell." One of the...

Guaranteed Detection of Temporary->Named Points

c++,c++11,design,move,lazy-evaluation
Suppose you write a matrix class with some operations: class matrix { public: double operator()(size_t i, size_t j) const; ... }; matrix operator*(const matrix &lhs, const matrix &rhs); ... It makes sense to defer the evaluation of some matrix expressions: m0 * m1 * m2 * m3 * m4 (which...

How should I represent a value of None when a [Flags] enum type doesn't define it?

c#,design,enum-flags
While working with XNA today, I noticed that one of the enum types that uses [Flags] did not have a None = 0 value: [Flags] public enum Buttons { DPadUp = 1, DPadDown = 2, DPadLeft = 4, DPadRight = 8, Start = 16, Back = 32, LeftStick = 64,...

C++, how to call functions when reading their ID number from a Mysql table?

c++,visual-c++,design
I have a Mysql table that I am using as a list of different calculations that needs to be done. Each line in the table has a column of type INT that has the number of the function that needs to be called. e.g. line 6, data, (function) 1. I...

Phantom margin/padding on top of parent div

html,css,css3,layout,design
Ok, so here's link to the problem: link The div's in question are the gray ones inside the green one. You'll notice that their width will fit inside of the parent (green). However, the float: left property on the child divs does nothing. Only, when adding float: left on the...

How to make REST API private?

api,rest,design
APIs like googlemaps API of facebook API are public and can be consumed by anybody. So my question is how do you make REST API private so it can be consumed only by choosen one consumer. For example You make Rest API only for your pwn AngularJS app. Is it...