paradigms

What are the pros and cons of error handling at beginning vs. end of the method

独自空忆成欢 提交于 2021-02-08 01:59:40
问题 In my programmer's experience, I have mixed error handling all the ways possible... I have created my personal style. However, I'd like to hear what you consider to be the pro and cons of error handling at the beginning vs at the end of the method. Handling at the beginning: public String GenerateSomeStringData(String data, int value) { if (data == null) throw new ArgumentNullException("data"); if (value <= 0) throw new ArgumentException("value must be greater than zero"); int dataValue; if (

Leaving recursive functions running forever?

橙三吉。 提交于 2021-02-05 08:10:53
问题 I came across a function where it had a setTimeout inside with a timeout growing exponentially (timeout *= 2) . let timeout = 10000 function foo() { // doSomething without breaking, returning setTimeout(foo, timeout) timeout *= 2; } foo() It seems that this should not be a problem and intuitively feels like setInterval is kinda doing the same already (having an infinite loop until it's cancelled if ever) , however, my question is in the approach itself. Is this something that could lead to

Leaving recursive functions running forever?

◇◆丶佛笑我妖孽 提交于 2021-02-05 08:10:28
问题 I came across a function where it had a setTimeout inside with a timeout growing exponentially (timeout *= 2) . let timeout = 10000 function foo() { // doSomething without breaking, returning setTimeout(foo, timeout) timeout *= 2; } foo() It seems that this should not be a problem and intuitively feels like setInterval is kinda doing the same already (having an infinite loop until it's cancelled if ever) , however, my question is in the approach itself. Is this something that could lead to

What is the rationale behind allowing variable shadowing in Rust? [closed]

纵饮孤独 提交于 2020-06-22 16:39:06
问题 Closed . This question is opinion-based. It is not currently accepting answers. Want to improve this question? Update the question so it can be answered with facts and citations by editing this post. Closed 5 months ago . Improve this question In Rust it is encouraged to shadow variables: But wait, doesn’t the program already have a variable named guess? It does, but Rust allows us to shadow the previous value of guess with a new one. Won't this feature just introduce problems like: hard to

tkinter and GUI programming methods

馋奶兔 提交于 2020-01-22 12:56:10
问题 Hopefully this doesn't fall under "general discussion topic", since I'd like it to be more about resolving these issues in an efficient manner than a giant debate about which general approach to GUI programming is the absolute best. So I've started some GUI programming with tkinter and long story short my code is getting pretty ugly pretty quickly. I'm trying to create a tile-based map editor for a video game. My main issues seem to be: the inability of callbacks to return values. the

Markup/Style best practices: How to efficiently distribute style rules over CSS classes?

半腔热情 提交于 2020-01-12 08:05:55
问题 Assume that I have some HTML page, and a corresponding CSS file. I'd like to add rounded corners to some elements. I want to alternate background colors on every other section. I want to add a hover state for each section heading. So forth and so on - I keep styling and styling and styling. It occurs to me that there are three extremes, where it concerns the "who, what, when, where, why and how" of distributing CSS rules over the markup by class, by id, and by hierarchy. Extreme #1: Every

Benefits of the “Convention over Configuration” paradigm

匆匆过客 提交于 2019-12-28 18:06:46
问题 What are the benefits of the "Convention over Configuration" paradigm in web development? And are there cases where sticking with it don't make sense? Thanks 回答1: Convention states that 90% of the time it will be a certain way. When you deviate from that convention then you can make changes...versus forcing each and every user to understand each and every configuration parameter. The idea is that if you need it to differ you will search it out at that point in time versus trying to wrap your

How to introduce AOP into productive software development?

六眼飞鱼酱① 提交于 2019-12-21 04:32:46
问题 I know this question has been asked before, but this was one and a half years ago, though I thought it might be the time for a re-questioning. I also recognized it might be seen as subjective, but I guess there are objective reasons for/against AOP. I would be interested in who is using AOP in software development and also why or why not using it. I see AOP as a very strong paradigm which can make a lot of development tasks easier. But when it comes to using AOP in real world projects I have