Today's Question:  What does your personal desk look like?        GIVE A SHOUT

SEARCH KEYWORD -- Assignment



  Bug caused by using changeable value as the default in "python method overload"​

In python we can set the passed in parameter's default value to make the function has the same running feature as the method overload in Java. Define a function like this: def testFunction(self, param1, param2=None, param3=None): Normally we use "None" as the parameter's default value. We can also use str/bool as the default value, but is it OK we use empty list [] as its default value? This is our test program: """ A test program using empty list as the passed-in parameter's default value. ...

   PYTHON     2019-03-11 08:52:52

  Eight C++ programming mistakes the compiler won’t catch

C++ is a complex language, full of subtle traps for the unwary. There is an almost infinite number of ways to screw things up. Fortunately, modern compilers are pretty good at detecting a large number of these cases and notifying the programmer via compile errors or warnings. Ultimately, any error that is compiler-detectable becomes a non-issue if properly handled, as it will be caught and fixed before the program leaves development. At worst, a compiler-detectable error results in los...

   C++,Compiler,Error detection     2012-04-08 09:55:20

  Go Lacks Ternary Operators. Here Are Some Equivalents

If you were like me, a pure Java developer before writing Go, you must be wondering why Go doesn’t support the ternary operator like return a > 1 ? 0 : 1. Most mainstream languages like C and Java are supportive of ternary operators; languages like Python and Ruby support the simplified if-else one-liner, such as a = 0 if a > 1. However, Go is not among them. And it is not only about adding operators but also a concept of coding in a more convenient way, such as the ?: expression can...

   GOLANG,TERNARY OPERATOR     2022-12-09 19:51:32

  6 Reasons Why Devs Should Learn Ruby on Rails

Ruby on Rails has during the last ten years become an increasingly popular framework for web app development. The current shaky economy and rapidly changing tech environment requires the art of app building to be faster and more cost-effective. That's why becoming fluent in Rails might be a great way for developers to expand their knowledge, which can land them a number of great jobs or interesting projects, as well as grant access to a thriving community. Let's start with the basics – wha...

   Ruby on Rails,Advantage     2014-07-25 10:56:29

  this in JavaScript in detail

this in JavaScript is always confusing, it is one of the most frequently seen traps in JavaScript. this is not a good design in JavaScript(You can refer some other design flaws of JavaScript here), since it's lazy binding feature, it can be a global object, the current object or.... Some people even avoid using this in JavaScript. Actually if you master how this works, then you will know how to stay away from these traps. Let's take a look at what this points to in below situations. 1. In global...

   JavaScript,this,bind     2013-05-09 18:35:12

  5 Tech Devices to Help You Succeed with an Online Master’s Degree

Studying for a master’s degree can be one of the best steps to take for your career and personal development. Whether you want to pursue an academic career and go on to gain further qualifications such as a doctorate, or want to use your master’s degree to further your career prospects, earn a promotion in your current job or even facilitate a career change, there are many reasons why more and more people are choosing to return to education. The opportunity to study for a master&rsqu...

   CAREER,MASTER,STUDY,TECH DEVICE     2019-05-29 10:46:07

  A couple of tips for beginning programmers

Whether it is football, quantum physics, a new foreign language or programming, the beginnings are problematic. What is more, no amount of advice can teach you as much as your own experience. Nevertheless, the following tips will help you avoid some mistakes, save your time and develop good programmer habits from the very beginning.Practise logical thinkingAlthough some may laugh at the stereotype of a programmer being a Maths genius, there is no use denying that learning Maths and Logics prepar...

   Programming,Tips,Beginner     2014-06-17 07:47:31

  When will resizing be triggered in Java HashMap?

HashMap is one of the most frequently used collection types in Java, it stores key-value pairs. Ideally it expects to use hash table which expects the data access time complexity to be O(1), however, due to hash conflicts, in reality, it uses linked list or red-black tree to store data which makes the worst case time complexity to be O(logn).  Although collections are using data structures like arrays and linked lists, unlike arrays, they will dynamically resize when there is not enough spa...

   JAVA,RESIZE,HASHMAP,THRESHOLD     2020-05-02 20:41:19

  Some frequently used ES6 code snippets

Below are a list of ES6 code snippets which are used frequently. Hope that it will be helpful. 1. Shuffle array elements let arr = [67, true, false, '55'] arr = arr.sort(() => 0.5 - Math.random()) console.log(arr) // [ '55', 67, false, true ] 2. Remove characters which are not numbers const str = 'xieyezi 23213 is 95994 so hansome 223333' const numbers = str.replace(/\D/g, '') console.log(numbers) // 2321395994223333 3. Reverse sequence or words const sentence = 'xieyezi js so handsome, lol.'...

   JAVASCRIPT,ES6,CODE SNIPPET,TIPS     2022-04-10 07:56:07

  Faster than C

Judging the performance of programming languages, usually C is called the leader, though Fortran is often faster. New programming languages commonly use C as their reference and they are really proud to be only so much slower than C. Few language designer try to beat C. What does it take for a language to be faster than C? Better Aliasing Information Aliasing describes the fact that two references might point to the same memory location. For example, consider the canonical memory copy: void...

   C,Performance,Speed,Fortran,Criteria     2012-03-25 09:12:23