design-decisions

Why doesn't my character sheet work with input() when trying to choose a race in a text based adventure? python3.x

妖精的绣舞 提交于 2020-02-06 06:23:45
问题 So this is just the beginning of a long line of questions I know that I am going to have. In this text based adventure I would like to eventually have puzzles and multiple branching paths, factions you can eventually join, choice dialogue that affects the morality of situations(like mass effect or kotor but.. text based-ish), etc., etc., but I feel like the early set up is VERY important for this learning journey. I also would like to eventually convert it over to PYQT5 and maybe eventually

Add simple business logic to repository in ASP>NET MVC 3 C#

巧了我就是萌 提交于 2019-12-24 07:27:14
问题 I have a question concerning an issue that has already been disputed many times in stackoverflow (I apologize for this) but no general answer has ever been given because of the subjectivity of the topic from one case to another: can we add business logic to the repository layer according to the repository pattern? I have an MVC 3 application with ViewModels (that means I don't use the ViewData at all). The model is an LinqtoSQL EF of course connected to a database. Currently I am accessing

What is the difference between using cfinvoke and createObject to run a component function?

帅比萌擦擦* 提交于 2019-12-23 09:26:53
问题 In my company's code, I've often seen component files used by initializing an object of that component and calling the methods off the object. However, it seems to me somewhat more straightforward to use the cfinvoke method, especially when only using one method from the component file. What are the differences between these 2 methods of calling a component function and what are the pros/cons of each? When should I use which? 回答1: cfinvoke can only be used in tags. createObject can be used in

Why are System.Drawing Rectangle, Point, Size etc mutable structs and not classes?

你离开我真会死。 提交于 2019-12-17 20:05:11
问题 Is there a reason Microsoft decided to make these structs? All three are mutable. I would find them much easier to deal with if they were either immutable, or if they were reference types. If there are reasons they must be structs, why are they mutable? 回答1: Why are they Structs Value Semantics There is no essential difference between two identical instances of these values. Any Point with coordinates, [2,3] is equal to any other point with the same coordinates, much like any two int s with

Why can't you create a setter without getter in scala?

那年仲夏 提交于 2019-12-12 03:37:21
问题 I found in Scala: can't write setter without getter? that you can't create a setter without getter: The interpretation of an assignment to a simple variable x = e depends on the definition of x. If x denotes a mutable variable, then the assignment changes the current value of x to be the result of evaluating the expression e. The type of e is expected to conform to the type of x. If x is a parameterless function defined in some template, and the same template contains a setter function x_= as

If the stack grows at numerically lower address why does pointer comparison reverses this?

血红的双手。 提交于 2019-12-11 11:33:37
问题 Since the stack grows downwards, ie towards numerically smaller memory addresses why does &i < &j is true. Correct me if I'm wrong, but I'd imagine this was a design decision of C creators (that C++ maintains). But I wonder why though. It is also strange that a heap-allocated object pin lies at numerically higher memory address than a stack variable and this also contradicts the fact that the heap lies at numerically smaller memory addresses than the stack (and increases upwards). #include

Why is CompareTo on short implemented this way?

久未见 提交于 2019-12-10 15:02:43
问题 Consider the following code: namespace ConsoleApplication1 { class Program { static void Main(string[] args) { Console.WriteLine(100.CompareTo(200)); // prints -1 Console.WriteLine(((decimal)100).CompareTo((decimal)200)); // prints -1 Console.WriteLine(((short)100).CompareTo((short)200)); // prints -100 Console.WriteLine(((float)100).CompareTo((float)200)); // prints -1 Console.ReadKey(); } } } My question is, are there any specific reasons the CompareTo-method on Int16 returns values other

What should I do with an object that should no longer be used in Perl?

泪湿孤枕 提交于 2019-12-07 11:12:45
问题 I am writing a class that is linked to an external resource. One of the methods is a delete method that destroys the external resource. No further method calls should be made on that object. I was thinking of setting a flag and die'ing inside of all of the methods if the flag is set, but is there a better, easier way? Something involving DESTROY maybe? So far, I am really liking Axeman's suggestion, but using AUTOLOAD because I am too lazy to recreate all of the methods: #!/usr/bin/perl use

What should I do with an object that should no longer be used in Perl?

佐手、 提交于 2019-12-05 17:40:42
I am writing a class that is linked to an external resource. One of the methods is a delete method that destroys the external resource. No further method calls should be made on that object. I was thinking of setting a flag and die'ing inside of all of the methods if the flag is set, but is there a better, easier way? Something involving DESTROY maybe? So far, I am really liking Axeman's suggestion, but using AUTOLOAD because I am too lazy to recreate all of the methods: #!/usr/bin/perl use strict; use warnings; my $er = ExternalResource->new; $er->meth1; $er->meth2; $er->delete; $er->meth1;