Book Image

Learning Object-Oriented Programming

By : Gaston C. Hillar
Book Image

Learning Object-Oriented Programming

By: Gaston C. Hillar

Overview of this book

Table of Contents (16 chapters)
Learning Object-Oriented Programming
Credits
About the Author
Acknowledgments
About the Reviewers
www.PacktPub.com
Preface
Index

Refactoring existing code in JavaScript


The following code shows an example of the declaration of the function that renders a sphere named renderSphere and the function that renders a cube named renderCube in JavaScript:

function renderSphere(
  x, y, z, radius, 
  cameraX, cameraY, cameraZ, 
  cameraDirectionX, cameraDirectionY, cameraDirectionZ, 
  cameraVectorX, cameraVectorY, cameraVvectorZ, 
  cameraPerspectiveFieldOfView, 
  cameraNearClippingPlane, 
  cameraFarClippingPlane, 
  directionalLightX, directionalLightY, directionalLightZ, 
  directionalLightColor) 
{

}

function renderCube(
  x, y, z, edgeLength, 
  cameraX, cameraY, cameraZ, 
  cameraDirectionX, cameraDirectionY, cameraDirectionZ, 
  cameraVectorX, cameraVectorY, cameraVvectorZ, 
  cameraPerspectiveFieldOfView, 
  cameraNearClippingPlane, 
  cameraFarClippingPlane, 
  directionalLightX, directionalLightY, directionalLightZ, 
  directionalLightColor) 
{

}

Each function requires a huge number of parameters. Let's imagine...