the meaning of lightweighted object [closed] - programming-languages

As it currently stands, this question is not a good fit for our Q&A format. We expect answers to be supported by facts, references, or expertise, but this question will likely solicit debate, arguments, polling, or extended discussion. If you feel that this question can be improved and possibly reopened, visit the help center for guidance.
Closed 10 years ago.
Please, gurus, give me a detailed explanation of, in the Object-Oriented programming world, what is lightweight object? And in other computer science fields, what does lightweight means then? Is lightweight a design pattern? Is lightweight good, is bad?

There are many meanings for lightweight, but normally it means the object which has less amount of data or which process less amount of data. Sometimes a thread is called as a lightweight process as it does a less things than a process do. Its processing is also fast than the process. A lightweight object is one which has less amount members and which are of basic types (int, float) as member variables. A light function is the one which does very less things compared to others. Normally these are inline functions. (in C context).
There is no such patterns as lightweight pattern. But Normally the systems should be consists of lightweight objects so that the maintaining those objects could be easy.
The advantages are simple debugging, maintenance and easy understanding of code. The disadvantage could be lots of objects.
There is no lightweight pattern as such but the term is fairly used in the industry.

Lightweight X tend to be used in the case where we have a somewhat well known structure X. Lightweight X is then a version of X using fewer resources in some way or the other - or is subtly different from X in some way.
The term, as is the case for most computer science, is not well-defined and is loosely used.

Related

Design Patterns for Multithreading [closed]

As it currently stands, this question is not a good fit for our Q&A format. We expect answers to be supported by facts, references, or expertise, but this question will likely solicit debate, arguments, polling, or extended discussion. If you feel that this question can be improved and possibly reopened, visit the help center for guidance.
Closed 9 years ago.
Multitasking seems to be a disaster at times when big projects crashes due to shared mutation of I would say shared resources are accessed by multiple threads. It becomes very difficult to debug and trace the origin of bug and what is causing it. It made me ask, are there any design patterns, which can be used while designing multithreaded programs?
I would really appreciate your views and comments on this and if someone can present good design practices which can be followed to make our program thread safe, it will be a great help.
#WYSIWYG link seems to have a wealth of useful patterns but i can give you some guidelines to follow. The main source of problems with Multi-Threaded programs is Update Operations or Concurrent Modification and some of the less occurring problems are Starvation, Deadlocks , etc which are more deadly if i may say, so to avoid these situations you can:
Make use of the Immutable Object pattern, if an object can't be modified after creation then you can't have uncoordinated updates and as we know the creation operation itself is guaranteed to be atomic by the JVM in your case.
Command Query Segregation Principle: that is separate code that modifies the object from code that reads them because reading can happen concurrently but modification can't.
Take huge benefit of the language and library features you are using such as concurrent lists and threading structures because they are well designed and have good performance.
There is a book (although an old one) but with very good designs for
such systems, it is called Concurrent Programming in Java.
Design patterns are used to solve a specific problem. If you want to avoid deadlocks and increase debugging, there are some dos and donts
User thread-safe library. .Net java, C++ have their own thread safe libraries. Use them. Don't try to create your own data structures.
If you are using .Net, try Task instead of threads. They are more logical and safe.
You might wanna look at list of some Concurrency related patterns
http://www.cs.wustl.edu/~schmidt/patterns-ace.html

performance of basic set theory (intersection, union, exclusion) over large sets of objects, which is faster linq in c# or f#? [closed]

As it currently stands, this question is not a good fit for our Q&A format. We expect answers to be supported by facts, references, or expertise, but this question will likely solicit debate, arguments, polling, or extended discussion. If you feel that this question can be improved and possibly reopened, visit the help center for guidance.
Closed 10 years ago.
I want to compare two collections of entity framework pocos based on union and intersection. I'm trying to find out if out of the box it would be better to process these sets using f# instead of linq?
You don't need to run a profiler -- F# 3.0 supports LINQ, so you should be able to put together a small benchmarking project which uses both LINQ and the standard F# Set<'T> and measures the time to complete whatever operations you need (use System.Diagnostics.Stopwatch for this).
Here's the thing -- the answer to this question is highly dependent on your exact needs, so you need to do a bit of testing to see which is faster for your use case. For example, if you create a little benchmark app and find that LINQ (in C# or F# 3.0) is faster by 10ms, do you just go with LINQ because it's faster? Maybe, or maybe not -- it depends on whether that 10ms savings is important for your application; in most cases, it probably isn't, so you should go with whatever solution is easiest to integrate with the rest of your code.
Personally, I'd go with F# 3.0 and LINQ here, because it allows for a very succinct definition, and it may also be faster if EF can offload some or all of the computation to the database server.

What are the main benefits of using Haskell for web developing? [closed]

As it currently stands, this question is not a good fit for our Q&A format. We expect answers to be supported by facts, references, or expertise, but this question will likely solicit debate, arguments, polling, or extended discussion. If you feel that this question can be improved and possibly reopened, visit the help center for guidance.
Closed 10 years ago.
I'm learning Haskell for great good.
I'm pretty into OOP and the various type systems. I used Java to develop webapps (Java EE, spring, Hibernate, struts 1.x), now I'm using regularly Python (pylons, django, sqlalchemy, pymongo) and Javascript. I had a huge improvement in my personal productivity: the lightweight approach, duck typing, awesome iterators, functions as first class citizens, simple syntax and configuration, fast tools like pip and distribute (and much more) helped me a lot.
But the first reason of my productivity boost is the Python language itself.
What are the main benefits of using Haskell for web developing?
For example, how its type inference can really improve my web app? So far, I noticed that when you decorate your function with its type-signature you are adding a lot of semantics to your program. I expect all this effort to come back in some way, to save many lines of code and to make them sound. I really like the sharp distinction between types and data, I'm starting to understand how they works, but I want something back :P
Don't get me wrong, I've just started studying Haskell so Maybe I'm missing some awesomness but I really want to understand its paradigm and when it's worth using it.
Most web applications aim to be stateless and handle concurrency well. Its also rather important to scale (Google SEO reasons, and user experience).
Haskell handles these problems rather well (although IMHO in more academic and perhaps less "human" intuitive way).
That being said due to the sheer lack of people doing web app dev (compared to say node.js) and that traditional web app dev has been more focused in a OOP mind frame it might be rather difficult.
I had some issues trying to use it as you can see in my questions below:
How do I do automatic data serialization of data objects?
Handling incremental Data Modeling Changes in Functional Programming

Common programming mistakes for Haskell developers to avoid? [closed]

As it currently stands, this question is not a good fit for our Q&A format. We expect answers to be supported by facts, references, or expertise, but this question will likely solicit debate, arguments, polling, or extended discussion. If you feel that this question can be improved and possibly reopened, visit the help center for guidance.
Closed 11 years ago.
In the spirit of the other common mistakes in questions, what are the most common mistakes that Haskell programmers make? I've been teaching myself Haskell for a little while and I am starting to feel comfortable enough with the language to start applying it in the real world.
The most common mistake I know of is introducing a space leak through lazy evaluation. There are lots of ways to achieve this mistake, but one that especially nails programmers with other functional-programming experience is to put a result in an accumulating parameter, thinking that the accumulating parameter will take constant space. In many cases the accumulating parameter takes linear space because parameters are not evaluated.
Another common mistake is to forget that let is always recursive. An unintentional
let x = ... x ...
can lead to baffling outcomes.
Most other common bad experiences manifest not as mistakes but as trouble getting programs past the type checker, or difficulty understanding the monadic I/O model. Difficulties with list comprehensions and with do notations occur occasionally.
In general the difficulties faced by beginning Haskell programmers include
Large language with many dark corners, especially in the type system
Trouble getting programs to compile, especially when they do I/O
Doing everything in the IO monad
Great difficulty predicting the time and space behavior of lazy functional programs
A common mistake for beginning Haskell programmers is to forget the difference between constructor and type namespaces. That was such a beginner's mistake that I'm about embarrassed to have my name attached to it, but I'm pretty confident that others will stumble upon that answer when they have a similar problem, so may as well keep it out there.
The difference between [] and [[]]: the empty list and the list with 1 element, namely the empty list. This one especially pops up in base cases of recursive functions.
Use non tail-recursive functions or not strict folds occurring to stack overflow.

Has anyone used "state machine" like schema in your project? [closed]

As it currently stands, this question is not a good fit for our Q&A format. We expect answers to be supported by facts, references, or expertise, but this question will likely solicit debate, arguments, polling, or extended discussion. If you feel that this question can be improved and possibly reopened, visit the help center for guidance.
Closed 10 years ago.
Define everything to do when something happens,
I really appreciate that,
but never have tried that yet.
my Q is :
How to design a state machine based system?
Have you looked at the State Pattern? Also here. Apache Commons SCXML might also be useful to you.
'State-event' driven architecture is used in quite a few application domains. In fact, there is a tool called smc (State Machine Compiler) that takes a specification for a state machine (much like lex and yacc take scanner and parser definitions) and generates code in C or other languages to implement it.
The basis of a state machine, in my experience, is the switch statement.
Each case within that represents a state of your machine.
The switch statement needs to be called on a regular basis, this can be within a coded loop, or within an event handler. It really depends on what your state machine is doing, how you want your software to run or react.
You update the state variable from within a case statement in order to change state.
Tons and tons of the little buggers.
I suggest that you look up the theoretical basis of finite state machines first and understand for what kind of tasks they are suitable for.
http://en.wikipedia.org/wiki/Finite state machine is a good place to start.

Resources