Posts

Showing posts from March, 2017

Kotlin Language Features Related to Null Handling

Any software engineer with a Java background would find the null handling features in the Kotlin language interesting. Let's summarize this topic with some examples. Nullable types: In Kotlin, types are non-nullable by default. If you want a variable to be able to hold a null value, you need to explicitly declare its type as nullable using the Type? syntax. For example, String? denotes a nullable string, while String represents a non-nullable string. Safe calls (?.): Kotlin introduces the safe call operator (?.) for handling nullable types. It allows you to safely invoke a method or access a property on a nullable object. If the object is null, the expression returns null instead of throwing a NullPointerException. Example: data class Person(val name: String, val age: Int, val address: String?) fun main() {     // Create a person with a nullable address     val person1 = Person("John Doe", 25, "123 Main Street")     val person2 = Person("Jane Doe", 30,

Simplescalar Simulator - Part 2: sim-outorder.c

sim-outorder implements a very detailed out-of-order issue superscalar processor with a two-level memory system and speculative execution support. This simulator is a performance simulator, tracking the latency of all pipeline operations. Let's have a look at SimpleScalar simulator's code related to iTLB. (Instruction Translation Lookaside Buffer) First, there are simulator options related to iTLB: /* register simulator-specific options */ void sim_reg_options(struct opt_odb_t *odb) { /* TLB options */ opt_reg_string(odb, "-tlb:itlb", "instruction TLB config, i.e., { |none}", &itlb_opt, "itlb:16:4096:4:l", /* print */TRUE, NULL); opt_reg_int(odb, "-tlb:lat", "inst/data TLB miss latency (in cycles)", &tlb_miss_lat, /* default */30, /* print */TRUE, /* format */NULL); } /* check simulator-specific option values */ void  sim_check_options(... ) { /* sim-outorder.c  line: 1098*/   /* u

Building and Testing Rest services with Spring

I realized that I need to learn more on Spring Boot/Spring REST and integration testing stuff. Here it goes! Let us remember: Spring Boot project aims at making it easier to build Spring applications by eliminating the need for extensive configuration. With default settings, you can feel magic tricks like implementing your interface behind the scenes etc. About REST : Have you ever worked with SOAP? How did it feel? For me, it always felt like something wrong was going on. Something simpler is needed. Then I was able to see in practice that REST services offer cleaner solutions and with the great capabilities of Java platform and Spring, you have a far better structure. HTTP is the Platform You describe the relationships using URIs. For example, you access the Bookmark's of a User with: /alice/bookmarks Clients and services agree upon a mutually understood data representation. So we send HTTP GET/POST/DELETE requests. There is usually a status code about the result of

Sharpening Regex Skills

Image
I needed to revisit regexes and found this sites useful: https://regexone.com https://regex101.com/ (Regex debugger is cool) Below is a useful summary: Groups: Parsing XML.. Following code creates 2 groups, then references to group 1.          boolean matchFound = false;          Pattern r = Pattern.compile("<(.+)>([^<]+)</\\1>");          Matcher m = r.matcher(line);          while (m.find()) {              System.out.println(m.group(2));              matchFound = true;          }                    if ( ! matchFound) {              System.out.println("None");          }

Java Interview Preparation

https://blog.udemy.com/java-interview-questions/ 1- What is JVM? Why is Java called the ‘Platform Independent Programming Language’? 2. What is the Difference between JDK and JRE? 3. What does the ‘static’ keyword mean? 4. What are the Data Types supported by Java? What is Autoboxing and Unboxing? 5. What is the difference between STRINGBUFFER and STRING? 6. What is Function Over-Riding and Over-Loading in Java? 7. What is Constructors, Constructor Overloading in Java and Copy-Constructor? 8. What is Java Exception Handling? What is the difference between Errors, Unchecked Exception and Checked Exception? Throwable       Error ( serious problems that a reasonable application  should not try to catch, out of memory etc. )       Exception             Checked / Unchecked 10. What is the Difference between byte stream and Character streams? A stream is a way of sequentially accessing a file. A byte stream access the file byte by byte. A byte stream is suitable for

Popular posts from this blog

Trie Data Structure and Finding Patterns in a Collection of Words

swapLexOrder: Finding lexicographically largest string

A Graph Application in Java: Using WordNet to Find Outcast Words