software-design

Untying Knuth's knots: how to restructure spaghetti code?

拜拜、爱过 提交于 2019-12-12 08:27:14
问题 This question was inspired by How to transform a flow chart into an implementation? which asks about ways of algorithmically eliminating the goto statement from code. The answer to the general problem is described in this scientific paper. I have implemented some code following the high-level sketch of Algorithm X from Knuth's The art of computer programming describing the generation of Lexicographic permutations with restricted prefixes (see p. 16 of this draft). This is the corresponding

Save and Get a Registry Value in 'HKEY_LOCAL_MACHINE\Software' using VB.NET

為{幸葍}努か 提交于 2019-12-12 06:38:53
问题 In my VB.NET project I want to save and get a registry value in "HKEY_LOCAL_MACHINE\Software" but I am only able to save and get it in "HKEY_LOCAL_MACHINE" but not software. Here is my code: For setting the value My.Computer.Registry.LocalMachine.SetValue("Study", "1") For getting the value Dim RegistryCheck As String = My.Computer.Registry.LocalMachine.GetValue("Study") 回答1: You have to verify if you have the permission to write (and also read) from HKEY_LOCAL_MACHINE. If you can't get the

JavaFX 2.0 render controls inside control

不打扰是莪最后的温柔 提交于 2019-12-11 19:28:02
问题 I work with .net WPF. Using this library allow me to completely redesign every control. F.e. - I've button, inside button I can render table (grid) with rows and columns. Then on specific cordination in table (grid) I can render image, label or something else. here is the example for redesign ListBoxItem <Style TargetType="{x:Type ListBoxItem}"> <Setter Property="Template"> <Setter.Value> <ControlTemplate TargetType="{x:Type ListBoxItem}"> <Grid x:Name="ShortCutGrid" Height="96"

Polymorphism vs Abstraction : Is polymorphism one of the way to achieve Abstraction?

你。 提交于 2019-12-11 15:07:42
问题 My understanding of a Polymorphism is, it is one of the way of achieving Abstraction ? Does every one agree with my view ? Or there is any flaw in my thinking ? 回答1: Polymorphism This is the ability to work with objects that react differently in a more efficient manner. The different object react differently, yet share the same methods. These methods are found in one common interface. For example if we were working with different types of ducks, we could say that they all have common things

Serverless python requests with long timeouts?

纵饮孤独 提交于 2019-12-11 07:38:53
问题 I have a several python scripts that follow a similar format: you pass in a date, and it either: - checks my S3 bucket for the file with that date in the filename, and parses it or - Runs a python script doing some analysis on the file of that date (which take over 1 hour to run) I am looking for a serverless solution that would let me call these functions on a range of dates, and run them all in parallel. Because of the long duration of my python script, services like AWS and Google Cloud

Does the program counter always have to change (upon a clock tick)?

余生颓废 提交于 2019-12-11 02:57:19
问题 I'm not so familiar with computing (software) theory, and I thought about this question - does the PC (program counter) always have to change (I guess, upon each new clock tick)? I searched a bit online, and found Commodore 64 Programmers Reference Manual ( heh :) ) that confirms it: " ...Commodore 64 (or, for that matter, any computer), the program counter is always changing " (as well as Chapter 6: Hard, soft or firm?); but I just wanted to have it commented here. I was thinking, if an

Initialize member of abstract class without subclasses having write access

烂漫一生 提交于 2019-12-11 02:38:51
问题 I have an abstract class: public abstract class AbstractCommand { private static State state; } Intention An object of class State is provided by some "controlling classes", providing data that is needed by each AbstractCommand subclass Each subclass needs read access to it The subclasses are not allowd to change the field Current approach The field state should be initialized by the "controlling classes" of the program so that subclasses (that define commands) can use it (read-only). The

re-design circular dependency flaw

家住魔仙堡 提交于 2019-12-10 21:03:21
问题 I've a bunch of small services that share some common packages like Logger , Configuration and Net . And I wrote each package in separated project. The issue is that my Logger needs package Configuration for set up. And my Configuration ( not solely used by Logger ) wants to write output log when necessary. Therefore, I've circular dependency flaw Logger --> Configuration , Configuration --> Logger . How can I redesign this code? 回答1: Something similar to this came up at GopherCon this year

Better solution than dynamic_cast in C++

时光怂恿深爱的人放手 提交于 2019-12-10 16:05:30
问题 I have a class hierarchy that I designed for a project of mine, but I am not sure how to go about implement part of it. Here is the class hierarchy: class Shape { }; class Colored { // Only pure virtual functions }; class Square : public Shape { }; class Circle : public Shape { }; class ColoredSquare : public Square, public Colored { }; class ColoredCircle : public Circle, public Colored { }; In part of my project, I have a std::vector of different type shapes. In order to run an algorithm

Entity Identity - use of strings instead of type

北战南征 提交于 2019-12-08 03:54:34
问题 I have seen a number of DDD posts and indeed books where entity classes are derived from some form of base class that has a generic parameter for the Entity Identity type: public interface IEntity<out TKey> { TKey Id { get; } } public interface IComplexEntity<out TKey, in TEntity> { TKey Id { get; } bool IsSameAs(TEntity entity); } //Object Definition public class TaxPayer : IComplexEntity<string, User> { ... } On Vernon's Implementing Domain Driven design, specific types are created for use