Search This Blog

Saturday, January 26, 2008

Microsoft : Double Thanks !!!

Peace be upon you

How are you guys? today and as unusual I will put some code, why??? Because I want someone to judge what I have done.

Let us take it from the beginning, I wrote this because I sent to Microsoft (I like to work there), I will sort it as I remember, Firs the Phone interviews, I will put only the question that I didn't answer
  • what is the difference between class and struct in C#?

  • - the difference is the struct is unmanaged object and class is managed object, what I mean , if you try to use sizeof which is located in (System.Runtime.InteropServices) you will see that it takes the unmanaged class or struct which means that the sturct is a some sort of unmanaged object,I found some similarity while I am trying, I found that the struct can inherit from interface, that's what I have tried I didn't try to inherit from class, but I think as long as it works with the interface it will work with class

  • P.S: I used VS.NET 2005 which has C# 2

  • what is the maximum number of functions in the dll?

  • - I don't remember exactly the question, so what I have tried is ,export some function using the ordinal, and I found it is Ok until it reaches to 65535, after that it give me linking error number 1119, how do I get it I will tell you.I though that when I read dll and when I use GetProcAddress using ordinal, I do some sort of casting to let it go, I imagined it like if it exceed that limition it will cause a problem to the GetProcAddress, why, simply because the function will not be able to know what is coming to it, is it string or ordinal, I have though also this limit is for the Unicode version of the GetProcAddress, there is 2 functions for GetProcAddress and here is sorting for this functions

  • GetProcAddressW : I think it's limit will be 65535

  • GetProcAddressA : this is the ASCII version and I think it's limit will be 255,

  • How does the Garbage collector works?

  • - as I told you before it manages the allocation and de-allocation of the memory, also the garbage collector works fine with objects that implement the IDisposable interface, this interface is like the destructor in C++, there is one thing about it the Garbage collector don't work efficiently when the developer uses "unsafe", the user have to manage the his/her pointer as he/she likes, I also read that the Garbage collector work with object in heap with it's status, what I mean is ,when the developer allocate object, the object is in LIVE mode, when the user change the object by allocating new object or any way, the old object get status DEAD, after that when the garbage collector pass over allocated object and it's status it de-allocate all object with status DEAD, logically, the garbage collector will call the "Dispose" if the object has the implementation of IDisposable.

Here is the answers for the form interview, it has the code that I told you about



As you look ahead to potential career opportunities, what are the “must have” criteria that you will be using to determine which opportunity is the right one for you?
1. The place where I can unleash my creativity power.
2. Place where I can be one of the technology leaders
3. Place that I have passion to be in like Microsoft (since I used DOS at 1998 I started dreaming to work there)



What is your strongest programming language (C, C++, C#, VB, Java, ASP, HTML, etc…)?
C# and C++

When was the last time you wrote C/C++ code?
Today

What percentage of your time do you spend writing code?
60%

Do you have experience with multi-threaded programming? If so please explain.
Yes, I will explain with sample of what I have done before over windows mobile.
Once there was tasked assigned to me and it was to allow user to draw in freehand style and after the user release the styles the application should calculate the size of the image with (Jpg) format.
I did a thread that works with low priority, I have added 2 flags:
· IsExit (used to de-allocate all memory and exit form the thread)
· IsReleased (Used to create the Jpg file and get its size), while it is happening the size label has the word "Loading…"
In this case I used the threading for avoiding the Interface freezing, there is other cases used to enhance the application performance and to make use of the hardware, for example to make use of the Hyper Threading processors the application must be well threaded, also it is applied on the processors with the multi core

How much experience do you have performing code and design reviews?
6 months
What percentage of code have you written was kernel mode and what percentage was user mode?
10% Kernel mode, 90% user mode

Please comment on your experience level and discuss projects worked on in the following areas as it relates to Test (if applicable):

Performance
Performance is the way of handling resources wisely, it is very important to do testing over the application performance for many reason, for example if the application is performance loose on mobile devices it will case a battery consumption.
Scalability
The application must be able to grow up and expand with the as user expects it, I don't have something in my mind related to testing right now
Stress Testing
It's away to test the application robustness on the huge load from users.
Microsoft provides tools for web stress test.
I have wrote application to test "Transaction server"
End to End testing
As I think this type of testing is to ensure that the business logic is correctly supported and working properly.
Simulation
I don't know much about it, but I wrote application that simulate the behavior of "POS client" to do stress test over the Transaction Server
Tuning
It's away to replace some working parts of the system with enhanced parts, like removing some code that takes long time to execute with code that is work better in the perspective of performance and correctly reach to the target
System Integration
This when new system is installed to older working system, in this type of testing the both systems should work correctly properly with effecting on each of the work negatively and also it should give the expected result form integration

Please respond to the below as it relates to your current project/product:

What percentage of your current project did you own?
30%
What percentage was of your design? How much was new code and how much was enhancements?
I don't understand the first part, 70% was new code and 30% was enhancement
What layer are you working on? (kernel, middleware, UI)

Kernel, Middleware
What percent of coding was yours on the project?
60%
How would you characterize your philosophy toward testing?
I don't know what does the question means but I will answer based on what I have understand,
For me testing is the core of perfection of the project, based one the feed back that testing gave me (what ever it was (unit test or release test)) it help me to enhance the product and reach with it to the optimum user satisfaction

How do you test your code? Someone else's?
I write some code to test it spending some time with debugging


Please complete each question and indicate how long each question took you to complete.

Write a function that would: return the 5th element from the end in a singly linked list of integers, in one pass, and then provide a set of test cases against that function.


Write me a function that receives three integer inputs for the lengths of the sides of a triangle and returns one of four values to determine the triangle type (1=scalene, 2=isosceles, 3=equilateral, 4=error). Generate test cases for the function assuming another developer coded the function



Write a function to reverse the words in a string (“cat and dog” becomes “tac dna god”).



Thanks for your time
BR
Ahmed Essam

Tuesday, January 22, 2008

NOW you can debug in dot NET Framework 3.5 source code

Peace be upon you

I hope that everyone is Ok, I will not talk too much there is very good article you should read about it

http://blogs.msdn.com/sburke/archive/2008/01/16/configuring-visual-studio-to-debug-net-framework-source-code.aspx


I found this link at My Dear brother Mohamed Milgy blog, he has published it and I just copied it here,
http://feeds.feedburner.com/~r/GuruStop/~3/218168429/microsoft-.net-framework-3.5-library-source-code-now-available.aspx

Thanks for your Time

BR
Ahmed Essam

Sunday, January 20, 2008

Performance presentation

Peace be upon you
today I am gonna show you something I hope that you like, I have moved to new company, in my last day I have done something to my colleagues at GET Group, by the way I was working there in project called "E-Purse" I really learnt a lot there, it was good, anyways what I have done to my colleagues was this presneation it is about preformance I hope that you like it, you may find a lot of mistakes in it :D, I wrote very late and it took me to stay to 3:30 AM to write it here it is.




Performance Analysis and enhancement
Software Performance issues
Performance analysis tools
Performance recommendation



Agenda

•Introduction
•Primitive performance tips
•Performance Issues:
–Web Application
–Desktop Application
•Performance Analysis tools



Performance and cost

•Performance enhancing is very resources consuming
•Developer should be aware of performance issues and how does the machine work, to produce reliable code.
•There is a rule that says, “you can’t have optimum available performance as long as you didn’t plane for that from the beginning”.
•In performance enhancement focus on what can be achieved and don’t get disturbed with the optimum.
•Performance tuning is endless, as much as you invest time on it as much you get better ideas about enhancing performance



Tuning levels and targets


•High:
–System level : improving application how it interact with the system
•Network traffic
•Disk performance
•Memory usage
–Application level: improving the algorithm
•Locks
•Heaps
•Threading algorithm
•API usage
–Computer architecture : improving how it works with the processor (loss the portability)



Memory Problems

•Memory Allocation and De-allocation.
–Any object you allocate you must de-allocate, there is many ideas about that “Smart pointers for examples”, for .NET you have to ensure that you are working correctly with the “Garbage collector”, the class you do must implement the “IDisposable” interface, in the areas that you want to be sure that GC works you have to use
–Using (Class object = new Class())
{
……
}
- Use GC.SuppressFinalize() ,Finalize() and destructors, don’t forget this things must be treaded carefully and wisely
•Memory fragmentation
–When you allocation and de-allocation memory with high rates, you cause memory fragmentation which means that your application cause of some kind of wholes in the memory, because system allocates heap as the application request this may cause application to crash



•Stack over flow.
–Be wise when doing recursive calls, this is main reason for the application to crash and cause of performance leak, there is other complicated way to do the task instead of recursive calls.
•Buffer over flow.
–You have to check every variable coming to your code, what ever the source of the input you have to check it and you have to be sure that the input is validate and match your use.
•which to use ( Virtual memory or heap ) : for .NET it is not issue anymore GC manage this issue, for C++ it is really big performance issue.



•Misaligned data: when you are working with some data structure you have to be sure that you are using or working with aligned data, misaligned data consume a lot of processor resources.
–Split loads and split stores
•This is like a big black whole that eats up your application performance
•Processors now get over it and handle this kind of problems “Misaligned data”, some doesn’t cover it, try it with Mobile application.



•SMID
–Single Instruction, Multiple Data
•SSE
–Streaming SIMD Extensions
•Hyper Threading
–One processor that is has the ability to use the unused resources as preparation for the next execution instauration
•Dual core
–One chip that has actually 2 processors, in labs they discover that putting 2 physical processor will increase the performance and will lower the power consumption, that’s why it became like a direction in manufacturing the processors
•Application with mobility
–What is your application behavior with computers that have batteries
–As long as your application consume a lot of processor performance as long as the processor consume the battery, so your application may cause a problem if its performance not enhanced



Over all application performance


•In general, when your application connects to database try to make it less touches.
–For example instead of executing 5 queries to do one task, try to enhance it to make it less count and less complexity, there is limitation with queries complexity
–Use indexes WISLY
–Fetch the data that is really needed, don’t get useless data, this is cost traffic.
–When you read from file from disk be wise with accessing file, each time you access the file it cost “Time”.
–Don’t bother user with interface complication because you want to have better performance.



Web Application performance


•Try as much as you can to make it less touches to the server
–Use the client side scripting, it really help a lot, to avoid round trips to the server, but don’t fully depend on it you may cause security bridge if you are over use it instead of server checks.
•Use AJAX it is really good because it save the traffic.
•Think about new way of handling data through web
–Check “Project Astoria”
http://blogs.msdn.com/astoriateam/
•It is new way to transfer data “PURE DATA” instead of mixed data and HTML (AJAX)



•Bewared of memory problems that we have mention before
•DO YOUR APPLICATION WELL THREADED
–Even when you run your application over Dual core or Hyper threading processor without good performance practice all that will seem to be nothing, because your application is single threaded or not well threaded.
–Hyper Threading and Dual core, is useful only with the good threaded application.














http://en.wikipedia.org/wiki/List_of_performance_analysis_tool
http://www.amd.com/us-en/Processors/DevelopWithAMD/0,,30_2252_869_3604,00.html
http://www.intel.com/cd/software/products/asmo-na/eng/vtune/239144.htm
http://www.ahmed-essam.com/2007/10/performance-tools-amd-vs-intel.html
http://ahmed-essam.com/2007/02/2_10.html
http://ahmed-essam.com/2007/02/1.html3


I hope you like it, thanks for your time.

BR
Ahmed Essam
There was an error in this gadget