Month: April 2012

test for integers in R

as.integer(x, ...)
integer(length = 0)
is.integer(x)

integer creates a integer vector of the specified length. Each element of the vector is equal to 0.

as.integer attempts to coerce its argument to be of integer type. The answer will be NA unless the coercion succeeds.

is.integer returns TRUE or FALSE depending on whether its argument is of integer type or not,

The weird thing I find when I am trying to use is.integer is, is.integer(3) will return false.

so what happens?

because

Becaues is.integer shows the internal representation, which is not an
integer but a double (real number). Some functions create integer vectors,
for example the : notation:

> is.integer(1:10) [1] TRUE

Or, is.integer(as.integer(3)) will also return TURE

Note:  is.integer(x) does not test if x contains integer numbers! For that, use round, as in the function is.wholenumber(x) in the examples:

is.wholenumber <-
    function(x, tol = .Machine$double.eps^0.5)  abs(x - round(x)) < tol

To test if a R object contains only integers:

!any(x!=as.integer(x))

Reference:

http://127.0.0.1:30947/library/base/html/integer.html

http://tolstoy.newcastle.edu.au/R/help/05/07/7671.html

https://stat.ethz.ch/pipermail/r-help/2006-January/086797.html


		
Advertisements

quality assurance的职位怎么样?_合集 mitbbs.com

Ans1: 1) it is harder to be a good QA
2) less control over the whole production process
3) probably always get a non-tech manager (both pro cand con)
4) sometimes less pay than development(not ncessary)

so, some people like to move out. usually the people who move out is above-avg since some other dept is willing to take them. the consequence is people who get left behind have to take more workload.

Ans2:好处,起点不是太高,如果要提高也有很多地方可以提高,pay得不少,按照IT的标准pay,基本和同级别的developer差不多坏处,似乎一起工作的女的比较多,印度女的,直接从印度f2h4过来的。是outsouce首选的部门。忙起来也比较要命,尤其产品将要production的时候。

如果真的选择这个行业,建议以后朝performance testing or test automation frame work多发展,这2个方向都需要一定的编程能力,是manual testing无法作的,很多manager的职位,甚至developer manager都是从做这个的中间选出来的。

另外,笔头功夫多练练,这个比较难,写出来的report要elegant,给人的印象深,容易升值

刚工作不久, 对于QA 的工作有很多疑惑, 不知哪位前辈能指点一下?

(1)我听说QA 有AUTOMATION QA , 可是目前我在一个小公司, QA TEAM 刚成立不久, 感觉AUTOMATION  方面不怎么样, 也就是用PERL 写写CODE, 能做一些简单的AUTOMATION, 比如, SUBMIT JOB, COMPARE RESULTS, 感觉应该有很多其他TOOL 可以用,不知其他QA 都用什么TOOL?
(2)没有受过关于QA 的任何培训(小公司), 不知从哪里可以找到QA 培训的材料, 课程, 可以学习一下。

(3) 关于QA 的CAEER PATH。怎样才能增加自己的VALUE, 使自己不容易别人代替?
(我觉得目前盼的活儿别人很容易就能取代我: 就是COLLECT TEST CASE, RUN REGRESSION, VERIFY TICKETS, 学一下 就能上手)

盼指点, 提前谢了!

http://www.boobooke.com/bbs/forum-8-1.html
http://www.boobooke.com/bbs/forum-10-1.html

some high level SDET can make >$180k a year. not to mention many company has “VP of product quality”…

【 在 windmaple (wind) 的大作中提到: 】
: 没啥职业前途,早点转吧

SDET的Career Path是什么?

测试的title分类比较乱,因为测试的技术相对于开发来说还很不成熟。一般有这个几个title,

1.SQA Analyst: 主要是manul testing,懂一点script或根本不懂。
2.SQA Engineer: 比SQA Analyst要高,要懂一些coding.
3.SDET/SET: MS是SDET,Google是SET.应该是绝大部分的工作focus在coding上。主要是做测试工具和自动化。其他公司很少这种职位。需要的coding比较好,算法比较好。基本上来说也就是developer了。只是在测试方面的developer.  SDET确实是最高的级别了。对SQA Analyst和SQAE来说的比较高级的automation的技术,对SDET来说是小儿科了。SDET有很多更深入的工作去做。

还有一些title,例如test developer,也差不多是SDET的意思。google的测试分两种,SQAE和SET,手工和自动测试的区别。微软现在可能只有SDET了。绝大部分公司最好的测试也就是SQAE.还有一种更高的title叫test architect. 现在市场上都没几个人能达到要求。

你这个没有普遍意义,反而容易误导。SDET很重要,而且会越来越重要。

软件工程里面,开发的方法逐渐成熟,没什么好创新的了,测试方法是个很好的领域。

QA不过是测试流程中间一步罢了。

我没做过SDE或者SDET,但我知道SDET是非常重要而且非常有价值的工作。这个里面关键的不是手工测试的过程,而是测试工具和方法的研究和改进,促进SDE能更有效率得写更高质量的代码。

【 在 shah (-1) 的大作中提到: 】
: 我看了微软一个员工得blog,抱怨他做sdet得时候还是受歧视的,最后
: 还是设法转到sde了

美国it公司分档_from mitbbs.com

第一档次: Dropbox, Square, Pinterest, Facebook, LinkedIn, Google, Twitter,
: Apple
: 第二档次: Zynga, Yelp, Netflix, Skype, VMWare, Salesforce, Groupon, Paypal
,
: Evernote, Box.net, Quora, A9.com, 126Lab, Yammer, Jive, Wikimedia,
: Craigslist
: 第三档次: Oracle, EMC, eBay, Intuit, NetApp, NetSuite, Yahoo, Adobe,
: Autodesk, Symantec, Riverbed, Quantcast, Concur, Aster Data, Citrix, EA等

算上湾区以外公司, Amazon, Micriosoft可以排在第二档次
Expedia, RedHat, RackSpace, Akamai, Bloomberg等可以排在第三档次

我是楼主,我希望大家不要把公司笼统归类了事。虽然每个公司对自己也有定位,但是
很多时候具体的offer也是因人而异。如果公司真的很需要你,给你涨个title,match
工资也可能发生的吧。

What is spinlock, Peterson’s algorithm,Semaphore (programming),Dining philosophers problem, paging, etc

http://en.wikipedia.org/wiki/Spinlock

http://en.wikipedia.org/wiki/Peterson%27s_algorithm

http://www.cs.uic.edu/~jbell/CourseNotes/OperatingSystems/6_Synchronization.html

http://en.wikipedia.org/wiki/Semaphore_(programming)

http://enos.itcollege.ee/~jpoial/docs/tutorial/essential/threads/deadlock.html starvation and deadlock

http://en.wikipedia.org/wiki/Paging

http://en.wikipedia.org/wiki/Virtual_memory

http://www.techinterviews.com/operating-system-questions

What is fragmentation? Different types of fragmentation? – Fragmentation occurs in a dynamic memory allocation system when many of the free blocks are too small to satisfy any request. External Fragmentation: External Fragmentation happens when a dynamic memory allocation algorithm allocates some memory and a small piece is left over that cannot be effectively used. If too much external fragmentation occurs, the amount of usable memory is drastically reduced. Total memory space exists to satisfy a request, but it is not contiguous.Internal Fragmentation: Internal fragmentation is the space wasted inside of allocated memory blocks because of restriction on the allowed sizes of allocated blocks. Allocated memory may be slightly larger than requested memory; this size difference is memory internal to a partition, but not being used

What is a Safe State and what is its use in deadlock avoidance? – When a process requests an available resource, system must decide if immediate allocation leaves the system in a safe state. System is in safe state if there exists a safe sequence of all processes. Deadlock Avoidance: ensure that a system will never enter an unsafe state.

What is CPU Scheduler? – Selects from among the processes in memory that are ready to execute, and allocates the CPU to one of them. CPU scheduling decisions may take place when a process: 1.Switches from running to waiting state. 2.Switches from running to ready state. 3.Switches from waiting to ready. 4.Terminates. Scheduling under 1 and 4 is non-preemptive. All other scheduling is preemptive.

Thrashing

When paging is used, a problem called “thrashing” can occur, in which the computer spends an unsuitable amount of time swapping pages to and from a backing store, hence slowing down useful work. Adding real memory is the simplest response, but improving application design, scheduling, and memory usage can help.

Journaling file system

http://en.wikipedia.org/wiki/Journaling_file_system

System development life cycle_SDLC

Not every project will require that the phases be sequentially executed. However, the phases are interdependent. Depending upon the size and complexity of the project, phases may be combined or may overlap.[7]

 

The SDLC is a process used by a systems analyst to develop an information system, training, and user (stakeholder) ownership. Any SDLC should result in a high quality system that meets or exceeds customer expectations, reaches completion within time and cost estimates, works effectively and efficiently in the current and planned Information Technology infrastructure, and is inexpensive to maintain and cost-effective to enhance.[2] Computer systems are complex and often (especially with the recent rise of service-oriented architecture) link multiple traditional systems potentially supplied by different software vendors. To manage this level of complexity, a number of SDLC models or methodologies have been created, such as “waterfall“; “spiral“; “Agile software development“; “rapid prototyping“; “incremental“; and “synchronize and stabilize”.[3]….

DOCUMENT OBJECT MODEL

From Wikepedia

The Document Object Model (DOM) is a cross-platform and language-independent convention for representing and interacting with objects in HTMLXHTML and XMLdocuments.[1] Objects in the DOM tree may be addressed and manipulated by using methods on the objects. The public interface of a DOM is specified in its application programming interface (API).

 

Standardization

The World Wide Web Consortium (W3C), founded in 1994 to promote open standards for the World Wide Web, brought Netscape Communications and Microsoft together with other companies to develop a standard for browser scripting languages, called “ECMAScript“. The first version of the standard was published in 1997. Subsequent releases of JavaScript and JScript would implement the ECMAScript standard for greater cross-browser compatibility.

After the release of ECMAScript, W3C began work on a standardized DOM. The initial DOM standard, known as “DOM Level 1,” was recommended by W3C in late 1998. About the same time, Internet Explorer 5.0 shipped with limited support for DOM Level 1. DOM Level 1 provided a complete model for an entire HTML or XML document, including means to change any portion of the document. Non-conformant browsers such as Internet Explorer 4.x and Netscape 4.x were still widely used as late as 2000.

DOM Level 2 was published in late 2000. It introduced the “getElementById” function as well as an event model and support for XML namespaces and CSS. DOM Level 3, the current release of the DOM specification, published in April 2004, added support for XPathand keyboard event handling, as well as an interface for serializing documents as XML.

By 2005, large parts of W3C DOM were well-supported by common ECMAScript-enabled browsers, including Microsoft Internet Explorer version 6 (2001)OperaSafari and Gecko-based browsers (like MozillaFirefoxSeaMonkey and Camino).

 

Web browsers

This section may require copy editing for grammar, style, cohesion, tone, or spelling. You can assist by editing it(September 2011)

Web browsers usually use an internal model similar to the DOM in order to render a document (such as an HTML page). The DOM APIs are also used to inspect or modify a Web page from JavaScript code. In other words, the Document Object Model is the way JavaScript sees the browser state and the HTML page it contains.

When an HTML page is rendered in a browser, the browser parses the markup (e.g. HTML), downloaded from the web-server into an in-memory DOM. The DOM is used to construct additional internal structures used to display the page in the browser window.

The nodes of every document are organized in a tree structure, called the DOM tree. The topmost node in the DOM tree is theDocument object. Each node has zero or more children.

An example of a DOM tree is shown below:

 |-> Document
   |-> Element (<html>)
     |-> Element (<body>)
       |-> Element (<div>)
         |-> text node
         |-> Anchor
           |-> text node
       |-> Form
            |-> Text-box
            |-> Text Area
            |-> Radio Button
            |-> Check Box
            |-> Select
            |-> Button

[edit]Implementations

Because DOM supports navigation in any direction (e.g., parent and previous sibling) and allows for arbitrary modifications, an implementation must at least buffer the document that has been read so far (or some parsed form of it).[citation needed]

[edit]Layout engines

Web browsers rely on layout engines to parse HTML into a DOM. Some layout engines such as Trident/MSHTML and Presto are associated primarily or exclusively with a particular browser such as Internet Explorer and Opera respectively. Others, such as WebKitand Gecko, are shared by a number of browsers, such as Google ChromeFirefox and Safari. The different layout engines implement the DOM standards to varying degrees of compliance.

Static methods in Class

When should we use static methods in class?

One rule-of-thumb: ask yourself “does it make sense to call this method, even if no Obj has been constructed yet?” If so, it should definitely be static.

So in a class Car you might have a method double convertMpgToKpl(double mpg) which would be static, because one might want to know what 35mpg converts to, even if nobody has ever built a Car. But void setMileage(double mpg) (which sets the efficiency of one particular Car) can’t be static since it’s inconceivable to call the method before any Car has been constructed.

(Btw, the converse isn’t always true: you might sometimes have a method which involves two Car objects, and still want it to be static. E.g. Car theMoreEfficientOf( Car c1, Car c2 ). Although this could be converted to a non-static version, some would argue that since there isn’t a “privileged” choice of which Car is more important, you shouldn’t force a caller to choose one Car as the object you’ll invoke the method on. This situation accounts for a fairly small fraction of all static methods, though.)

Define static methods in the following scenarios only:

  1. If you are writing utility classes and they and they are not supposed to be changed.
  2. If the method is not using any instance variable.
  3. If any operation is not dependent on instance creation.
  4. If there is some code that can easily be shared by all the instance methods, extract that code into a static method.
  5. If you are sure that the definition of the method will never be changed or overridden. As static methods can not be overridden.

In general, if your situation requires encapsulation of state or an organizational structure, then you will be using classes.

On the other hand, if you have something that is a cross-cutting concern, and can be used broadly across your application, you might consider methods in a static utility class. System.Math in the .NET framework (and Java) is an example of this.

Question:

I’m refactoring some code and I’m looking at a class called HFile. HFile has all private constructors so that you can actually create instances of it. Instead of creating instances of HFiles as follow:

var file = new HFile('filename') file.Save() 

All HFile interaction is handled via static methods. So if I wanted to save a file I would call:

HFile.save('filename') 

and then internally an instance of HFile would be created and then saved. Obviously without knowing the whole story any reader must reserve judgment, but it seems like using static methods has become very fashionable at my place of work. So I’m wondering if there are good principles/best practices for usage of static methods that can helpful for a group of guys sitting down and reviewing their usage of static methods.

Answer:

In your example, HFile is probably an object with state, so I would not generally use a static method to save it. It’s simpler just to make a method call on the specific HFile object, rather than having to pass the entire object to a static method for saving. Whether that makes sense or not in your particular application depends on whether your application’s paradigm sees HFile objects as things to be passed around and acted on by outside methods, or as standalone objects capable of saving themselves.

After reading Misko’s articles I believe that static methods are bad from a testing point of view. You should havefactories instead(maybe using a dependency injection tool like Guice).

how do I ensure that I only have one of something

only have one of something The problem of “how do I ensure that I only have one of something” is nicely sidestepped. You instantiate only a single ApplicationFactory in your main, and as a result, you only instantiate a single instance of all of your singletons.

The basic issue with static methods is they are procedural code

The basic issue with static methods is they are procedural code. I have no idea how to unit-test procedural code. Unit-testing assumes that I can instantiate a piece of my application in isolation. During the instantiation I wire the dependencies with mocks/friendlies which replace the real dependencies. With procedural programing there is nothing to “wire” since there are no objects, the code and data are separate.

An article worthy of reading: Static Methods are Death to Testability

Curiously recurring template pattern(CRTP)

http://en.wikipedia.org/wiki/Curiously_recurring_template_pattern

” The curiously recurring template pattern (CRTP) is a C++ idiom in which a class X derives from a class template instantiation using X itself as template argument.[1]

how to use CRTP to achieve independent variables for static variables defined in a base class:

http://stackoverflow.com/questions/2737013/static-variables-in-static-method-in-base-class-and-inheritance

http://stackoverflow.com/questions/169378/c-sharp-method-can-be-made-static-but-should-it/169423#169423